The password-answer supplied is invalid. Create User using CreateUserWizard without entering Security Question and Answer fields

Filed in .Net Leave a comment

I need to create user using CreateUserWizard of ASP.Net Membership. By default Security Question and Answer fields are mandatory when you drag and drop the wizard. I need to create user without these fields. For this you need to set “requiresQuestionAndAnswer” flag to false in web.config membership provider setting area. After that you can remove Security Question and Answer fields from aspx  page. Below is the sample code of my web.config.

<membership defaultProvider=”CustomizedProvider”>

<providers>

<add name=”CustomizedProvider” type=”System.Web.Security.SqlMembershipProvider”

connectionStringName=”DinnerINN”

applicationName=”DinnerINN”

minRequiredPasswordLength=”5″

minRequiredNonalphanumericCharacters=”0″

requiresQuestionAndAnswer=”false”

maxInvalidPasswordAttempts=”5″ />

</providers>

</membership>

Data Handling in ASP.Net DetailsView

Filed in .Net Leave a comment

I have a date field in my DetailsView and the date which is coming from DB is the default date which is “1/1/1754 5:00:00 AM”. I need to set the value of this template field to “N/A” if it is default date.

I created below method in my code behind.

protected string ReplaceDefaultDateAsNA(DateTime discontinued)

{

if (discontinued.ToString() == “1/1/1754 5:00:00 AM”)

{return “N/A”;}

else

{return discontinued.ToString();}

}

Template field in DetailsView looks like.

<ItemTemplate>

<asp:Label ID=”Label6″ runat=”server” Text=’<%# ReplaceDefaultDateAsNA((DateTime) Eval(“LastPasswordChangedDate”)) %>’></asp:Label>

</ItemTemplate>

Reference (very good article): http://static.asp.net/asp.net/files/DataTutorials/datatutorial13cs.pdf

Check at least one checkbox is selected in CheckBoxList using ASP.Net Validators

Filed in .Net | Javascript Leave a comment

I found a very good article to check that at least one chekbox is selected in a checkboxlist control. Works exactly like required field validator.

http://forums.asp.net/t/1000658.aspx (check answer from user yasserzaid)

<script type=”text/javascript”>

function ValidateRolesSelection(source, args)

{

//if your checkboxlist control is on simple asp.net page

var chkListModules = document.getElementById(‘<%= RolesCheckBoxList.ClientID %>’);

//if your checkboxlist control is inside some user control for e.g in CreateUserWizard

//var chkListModules = document.getElementById(‘<%= (CreateUserWizard1.WizardSteps[0].Controls[0].FindControl(“RolesCheckBoxList”) as CheckBoxList).ClientID %>’);

var chkListinputs = chkListModules.getElementsByTagName(“input”);

for (var i = 0; i < chkListinputs.length; i++)

{

if (chkListinputs[i].checked)

{

args.IsValid = true;

return;

}

}

args.IsValid = false;

}

</script>

ClickOnce application installed path

Filed in ClickOnce Leave a comment

The path of the ClickOnce installed application is sort of hidden. Below is the sample path;

C:\Documents and Settings\USERNAME\Local Settings\Apps\2.0\OZNAN8K7.K0W\P7TP6M3R.WZ4\AppDllName…..WEREWC.334

USERNAME: Is the logged user name.

The second last and third last folder name differ from machine to machine but sort of garbage name.

AppDllName…..WEREWC.334: Last folder name start from application dll name then “…” and then again some garbage.

Mailbox unavailable. The server response was: 5.7.1 Client does not have permission to send as this sender

Filed in .Net Leave a comment

I got this error when I am trying to send mail using System.Net.Mail. I got this error because our exchange server does not relay those emails in which From Address and Reply To Address are different. I have a requirement that both need to be different, for this network administrator must need to allow this thing in exchange server.

Checking character/string length using .net validators

Filed in .Net | Javascript Leave a comment

I need to check character length between 9 to 24 need to be all numbers. I have applied below regular expression validator.

<asp:RegularExpressionValidator ID=”revBankAccountNo” runat=”server” ControlToValidate=”txtBankAccountNo” Display=”Dynamic” SetFocusOnError=”True” ValidationExpression=”^[0-9]{4,24}$”>*</asp:RegularExpressionValidator>

I need to check character length to be exact 9. I have applied below regular expression validator.

<asp:RegularExpressionValidator ID=”revBankAccountNo” runat=”server” ControlToValidate=”txtBankAccountNo” Display=”Dynamic” SetFocusOnError=”True” ValidationExpression=”^[0-9]{9}$”>*</asp:RegularExpressionValidator>

Error in deploying cyrstal report developed in VS2008 ASP.NET

Filed in .Net Leave a comment

If you developed crystal report in VS2008 for your web project and you need to deploy it on production or test server where VS is not installed. You need to install crystal runtime on server in order to view your report. Crystal runtime can be found very easily on development machine.

C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5

CRRedist2008_x64.msi (For 64 bit Machine)

CRRedist2008_x86.msi (For 32 bit Machine)

Could not load file or assembly ‘System.Web.Extensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35′ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0×80131040)

Filed in .Net Leave a comment

I got this error when I am trying to create a report using Crystal Reports tool included in VS2008 with .NET 3.5 SP1. I also have VS2005 installed. I found perfect solution on the below website but must consider the scenario.

http://sjc.ironspeed.com/post?id=3039720

Restoring a previous version of ClickOnce deployed application

Filed in ClickOnce Leave a comment

This is a very common scenario that you need to restore the older version of release and your application is deployed via ClickOnce method. Below are the some links which I found found very useful in order to resolve this issue.

http://geekswithblogs.net/gpro/archive/2008/10/30/clickonce-restore-previous-version.aspx

http://www.codeproject.com/KB/dotnet/Restore_Application.aspx

http://www.infoq.com/articles/ClickOnce-Versioning

Enforce user to update the newly deployed ClickOnce release

Filed in ClickOnce Leave a comment

Problem:

There are some time where you would like the user to forcely update the release which is deployed via ClickOnce.

Solution:

Right Click Project > Properties > Publish Tab > Click Updates… buttons > Check the option (Specify a minimum required version for this application) to the latest version. With this option when user open the application it will automatically update the specified version.

TOP