Tuesday, March 18, 2014

Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.



This error comes up when the web application is using different version of framework than IIS

To fix this problem first check which framework your application is using, by right click on the project and click on properties

After than open up IIS and Double click on Application Pools

On the right panel double on your website and select the appropriate framwork version

That's it and now your website should work

I hope it was informative for you and I would like to Thank you for reading

Tuesday, March 11, 2014

How to change css from Code Behind

Normally css is changed though jQuery but in this tutorial I will show you how you can change a control css from code behind.

First we need to find the control

HtmlControl myControl1 = (HtmlControl)Page.Master.FindControl("Label1");
         
            myControl1.Attributes.Add("style", "display:none");


In the above example we are first finding an element Label1 which is inside our master page, after finding the control we are saving it in myControl1 who's type is HtmlControl

Now using Control1.attributes.Add()

We can add any css

I hope it was informative for you and I would like to Thank you for reading         

Tuesday, March 4, 2014

Insert default text in TextBox ASP.NET

You can insert default text in TextBox to assist your users what value to insert in the Textbox


            onBlur="if (this.value=='') this.value = 'Default Value'" onfocus="if (this.value=='Default Value') this.value = ''

When the Textbox looses focus it's value will automatically changes to Default Value and when the focus is inside the control its Default value will change so that user can type

I hope it was informative for you and I would like to Thank you for reading.

Monday, March 3, 2014

Make Email address unique in create User Wizard ASP.NET

in createuserwizard the userid is unique by default

But in some cases we want to make both user id and email address unique so that a single user don't create multiple account.

we have 2 options

First option is that we can either edit the aspnet membership database and make userId and email as composite key which is not easy

2nd option is to this membership rule in web.config of our project

I will be using option number 2 for this tutorial

add the following taf in your web.config replace the name of connectionStringName as per your requirement

    <membership defaultProvider="CustomizedMembershipProvider">
      <providers>
        <add name="CustomizedMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" requiresUniqueEmail="true" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" minRequiredPasswordLength="8" minRequiredNonalphanumericCharacters="1"/>
      </providers>
    </membership>


I hope it was informative for you and I would like to Thank you for reading.