Archive

Archive for April, 2014

Change Hashed Password using ASP.Net Membership Provider

April 19, 2014 Leave a comment

Hi all,

try this example to Change Hashed Password using ASP.Net Membership Provider

Since you are using Hashing, you can’t retrieve password back from database, so you must reset it before assigning new password like as shown here

string password = "pass@word";
MembershipUser mu = Membership.GetUser();
mu.ChangePassword(mu.ResetPassword(), password);

and In Web.Config File add Membership Configuration :

<membership defaultProvider="SqlMembershipProvider" userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="SqlMembershipProviderOther" type="SqlProviderOneShot.SqlMembershipProvider"
requiresQuestionAndAnswer="false"
connectionStringName="ConnectionString" applicationName="/"
enablePasswordRetrieval="false" enablePasswordReset="true"
requiresUniqueEmail="true" passwordFormat="Hashed"
minRequiredNonalphanumericCharacters="0" writeExceptionsToEventLog="false"
minRequiredPasswordLength="1" passwordStrengthRegularExpression=""
passwordAttemptWindow="10" maxInvalidPasswordAttempts="8"/>
</providers>
</membership>

Hope this helps

Good Luck.

Categories: ASP.Net

Open Popup Window on click of Link Button inside GridView in ASP.Net

April 18, 2014 Leave a comment

Hi all,

try this example to open Popup Window on click of Link Button inside GridView in ASP.Net

— ASPX Page :

<div>
<asp:GridView ID="gvDemo" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:TemplateField HeaderText="">
<ItemTemplate>
<a href="#" onclick='openWindow("<%# Eval("Code") %>");'>View Details</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<script type="text/javascript">
function openWindow(code) {
window.open('page.aspx?Code=' + code, 'open_window', ' width=640, height=480, left=0, top=0');
}
</script>

— In Code behind :

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[2]{
new DataColumn("Code", typeof(int)),
new DataColumn("Name", typeof(string)) });
dt.Rows.Add(1,"Yasser");
dt.Rows.Add(2,"Ahmed");
dt.Rows.Add(3,"Zaid");
gvDemo.DataSource = dt;
gvDemo.DataBind();
}
}

Hope this helps

Good Luck.

Categories: ASP.Net, Javascript

Hide fields in NewForm, EditForm and DispForm in SharePoint 2010

April 11, 2014 Leave a comment

Hi all,

In this post we will discuss how we can hide a field in SharePoint list forms such a NewForm, EditForm or DispForm

Suppose you have a list that contains some fields and you want some fields should not appear in some forms.

We can do this by using the SPField class.

using (SPSite site = new SPSite("http://sharepoint.contoso.com"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["Employees"];
SPField field = list.Fields["Salary"];
field.ShowInNewForm = false;
field.ShowInEditForm = false;
field.ShowInDisplayForm = false;
field.Update();
}
}

Hope this helps

Good Luck.

Categories: SharePoint 2010

Lock Application for Maintenance

April 7, 2014 Leave a comment

Hi all,

try this example to show how to Lock application for maintenance

In Your Master Page add this code

if (ConfigurationManager.AppSettings["IsActiveApplication"] != null)
{
// -- Activate system [1=Active,0 = not active]
if (ConfigurationManager.AppSettings["IsActiveApplication"] == "0")
{
Response.Redirect("~/UnderMaintenance.htm");
}
}

In Web.Config add this line in AppSettings Section

<!--Activate system [1=Active,0 = not active]-->
<add key="IsActiveApplication" value="1"/>

Hope this helps

Good Luck.

Categories: ASP.Net

JQuery to prevent Cut , Copy , Paste and Drop options in Textbox

April 4, 2014 1 comment

Hi all,

try this example to use JQuery to prevent Cut , Copy , Paste and Drop options in Textbox

<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
var controls = $(".disable");
controls.bind("paste", function () {
return false;
});
controls.bind("drop", function () {
return false;
});
controls.bind("cut", function () {
return false;
});
controls.bind("copy", function () {
return false;
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
ASP.Net<br />
<br />
<asp:TextBox ID="TextBox2" runat="server" CssClass="disable"></asp:TextBox><br />
<br />
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" CssClass="disable"></asp:TextBox><br />
<br />
<br />
</form>
</body>

Hope this helps

Good Luck.

Categories: ASP.Net, Jquery