Enable Approve/Reject Function for Approval Workflow in SharePoint

January 20, 2018 Leave a comment

Hi all,

I will show you how to Enable Approve/Reject Function for Approval Workflow in SharePoint 2010

Xuhwg

In the settings for the document library or List do the following:
1- Click “Versioning Settings”
2- For “Require content approval for submitted items?” I selected “Yes”
This allowed me to approve and reject the documents or List in the workflow.

Good Luck

Advertisements
Categories: SharePoint 2010

Login failed for user IIS APPPOOL\AppPool4.5 or APPPOOL\ASP.NET

December 5, 2017 Leave a comment

Dears,

In this post i will provide a solution for error “Login failed for user IIS APPPOOL\AppPool4.5 or APPPOOL\ASP.NET”

This Error usually occurs when you configure a new website in IIS or move an existing website to a newer version of IIS.
A simple solution to the error is to add a login to SQL Server for IIS APPPOOL\ASP.NET v4.5 and grant appropriate permission to the database.
Open SQL Server Management Studio > Right click ‘Security’ > New > Login

iis-apppool-login[5]

In the dialog that appears, enter the app pool ‘IIS APPPOOL\AppPool4.5’ as the login name then click Ok

sqlserver-apppool[3].png

Now expand Logins in SSMS and select this newly created login. Right Click > Properties. Click on User mapping and map this login to the database you want to provide access to.
Also select the appropriate roles for this user.

usermapping[2]

Hope this helps

Good Luck.

Categories: SQL Server

Display Progress Bar In GridView

November 9, 2017 Leave a comment

Hi all,

Try this example to display Progress Bar In GridView

<div>
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
<asp:BoundField DataField="Percentage" HeaderText="Percentage" ItemStyle-Width="150" />
<asp:TemplateField ItemStyle-Width="300">
<ItemTemplate>
<div class='progress'>
<div class="progress-label">
<%# Eval("Percentage") %></div>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<style type="text/css">
.ui-progressbar
{
position: relative;
}
.progress-label
{
position: absolute;
left: 50%;
top: 4px;
font-weight: bold;
text-shadow: 1px 1px 0 #fff;
}
body
{
font-family: Arial;
font-size: 10pt;
}
</style>
	<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/start/jquery-ui.css">
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script> 
<script type="text/javascript" src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script type="text/javascript"> 
 $(function () { 
 $(".progress").each(function () { 
 $(this).progressbar({ 
 value: parseInt($(this).find('.progress-label').text()) 
 }); 
 }); 
 }); 
</script> 

In code behind :

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Percentage",typeof(string)) });
dt.Rows.Add(1, "John Hammond", 45);
dt.Rows.Add(2, "Mudassar Khan", 37);
dt.Rows.Add(3, "Suzanne Mathews", 67);
dt.Rows.Add(4, "Robert Schidner", 12);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}  

Hope this helps

Good Luck.

Categories: ASP.Net, Javascript, Jquery

Send Email with Attached file in ASP.NET MVC 5

October 11, 2017 Leave a comment

Hello,

In this example i will show how to Send Email with Attached file in ASP.NET MVC 5

1. Create a new Model Class in the model

namespace SendEmailwithAttchedFile.Controllers
{
    public class EmailModel
    {
        public string To { get; set; }
        public string Subject { get; set; }
        public string Body { get; set; }
    }
}

2. Create a new Home Controller in the Controller and an Email Action with HttpPost method in the Home Controller

using System.IO;
using System.Net;
using System.Net.Mail;
using System.Web;
using System.Web.Mvc;

namespace SendEmailwithAttchedFile.Controllers
{
    public class HomeController : Controller
    {
        [HttpPost]
        [ActionName("Email")]
        public ActionResult SendAttachEmail(EmailModel objModelMail, HttpPostedFileBase Attachedfile)
        {
            if (ModelState.IsValid)
            {
                string from = "youremail@gmail.com"; //Email like- anil.singh581@gmail.com
                using (MailMessage mail = new MailMessage(from, objModelMail.To))
                {
                    mail.Subject = objModelMail.Subject;
                    mail.Body = objModelMail.Body;
                    if (Attachedfile != null)
                    {
                        string fileName = Path.GetFileName(Attachedfile.FileName);
                        mail.Attachments.Add(new Attachment(Attachedfile.InputStream, fileName));
                    }
                    mail.IsBodyHtml = false;
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host = "smtp.gmail.com";
                    smtp.EnableSsl = true;
                    NetworkCredential networkCredential = new NetworkCredential(from, "your@Password");
                    smtp.UseDefaultCredentials = true;
                    smtp.Credentials = networkCredential;
                    smtp.Port = 587;
                    smtp.Send(mail);

                    ViewBag.Message = "EmailSent";

                    return View("Index", objModelMail);
                }
            }
            else
            {
                return View();
            }
        }
    }   
}

3. In Home View

</pre>
@model SendEmailwithAttchedFile.Controllers.EmailModel
@{
ViewBag.Title = "Index";
}
<h3>Send Email With Attached File</h3>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>

@using (@Html.BeginForm("Email", "Home", FormMethod.Post, new { @id = "form1", @enctype = "multipart/form-data" }))
{
 @Html.ValidationSummary()

<div>

<table>

<tbody>

<tr>

<td>To:</td>


<td>@Html.TextBoxFor(m => m.To)</td>

</tr>


<tr>

<td>Subject:</td>


<td>@Html.TextBoxFor(m => m.Subject)</td>

</tr>


<tr>

<td>Attachment</td>


<td><input name="Attachedfile" type="file" /></td>

</tr>


<tr>

<td>Body:</td>


<td>@Html.TextAreaFor(m => m.Body)</td>

</tr>

</tbody>

</table>

</div>


<div><input type="submit" value="Send" /></div>

}

<script type="text/javascript">
$(function () {
 if ('@ViewBag.Message' === 'EmailSent') {
 alert('Email has been sent successfully!');
 }
});
</script>
<pre>

Hope this helps

Categories: MVC

Solve Error “The query cannot be run for the following DataObject: InfoPath cannot run the specified query. Access is denied”

September 7, 2017 Leave a comment

Dear,

In this post i will show how to Solve error “The query cannot be run for the following DataObject: InfoPath cannot run the specified query. Access is denied”

– Open the form in InfoPath
– Click on File – Form Options
– Click on Security and Trust
– Make sure Full Trust is checked

Hope this helps

Good Luck

Categories: InfoPath

Creating Directory or Folder using ASP.Net

August 16, 2017 Leave a comment

Hi all,

Try this example to Create Directory or Folder using ASP.Net

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CreateFolder.aspx.cs" Inherits="CreateFolder" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="margin-top: 40px; margin-left: 50px;">
<h3>Create folder on server using c#</h3>
Folder Name :
<asp:TextBox ID="txtFolderName" runat="server" Width="186px"></asp:TextBox>&nbsp;<asp:Button ID="btnCreateFolder" runat="server" Text="Create Folder" OnClick="btnCreateFolder_Click" />
<asp:Button ID="btnDelete" runat="server" Text="Delete Folder" OnClick="btnDelete_Click" />
<asp:Label ID="lblError" runat="server" Style="color: #FF0000; font-weight: 700"></asp:Label>
</div>
</form>
</body>
</html>

In code behind :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class CreateFolder : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnCreateFolder_Click(object sender, EventArgs e)
{
string directorypath = Server.MapPath(txtFolderName.Text);
if (!Directory.Exists(directorypath))
{
Directory.CreateDirectory(directorypath);
lblError.Text = "Folder/Directory Created successfully";
}
else
{
lblError.Text = "Folder/Directory already exists";
}
}
protected void btnDelete_Click(object sender, EventArgs e)
{
if (txtFolderName.Text != "")
{
string directorypath = Server.MapPath(txtFolderName.Text);
if (!Directory.Exists(directorypath))
{
lblError.Text = "Folder/Directory not found";

}
else
{
Directory.Delete(directorypath);
lblError.Text = "Folder/Directory Deleted successfully";
}
}
else
{
lblError.Text = "Please enter folder name for delete";
}
}
}

Hope this helps

Good Luck.

 

Categories: ASP.Net

Get and Bind all Countries to DropdownList Using Globalization

July 17, 2017 Leave a comment

Hi all,

Try this example to Get and Bind all Countries to Dropdownlist Using Globalization

Select Country:

<asp:DropDownList ID="ddlcountry" runat="server"> </asp:DropDownList>

In Code behind :


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetAllCountry();
}
}

public void GetAllCountry()
{
try
{
List<string> listcountry = new List<string>();
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
foreach (CultureInfo cinfo in cultures)
{
RegionInfo Rinfo = new RegionInfo(cinfo.LCID);
if (!listcountry.Contains(Rinfo.EnglishName))
{
listcountry.Add(Rinfo.EnglishName);
}
}
listcountry.Sort();
ddlcountry.DataSource = listcountry;
ddlcountry.DataBind();
ddlcountry.Items.Insert(0, new ListItem("--Select Country--", "0"));
}
catch (Exception ex)
{
}
}

Hope this helps

Good Luck

Categories: ASP.Net