Wednesday 20 March 2013

404.2 The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the Web server


By default IIS 7 does not allow ISAPI and CGI through .Net 4.0. So if you are working with older code on IIS 7 you will need to follow these steps to resolve the issue:

      
     Open IIS and click the server name



2. Double click “ISAPI and CGI Restrictions”

3. Right click ASP.NET v4.0.30319 and select “allow”





1.     Go to Start > All Programs > Administrative Tools > Services.

2.     In the services list, right-click World Wide Web Publishing Service, and then   click Stop (to stop the service), Start (to start it after it has been stopped), or Restart (to restart the service when it is running).


Tuesday 19 March 2013

Set html body background image using asp.net


Introduction:
I have scenario that I have admin setting for back ground. Whatever image I uploaded. I want to set dynamic background image on body of form.

Approach
 My approach is to get image from database with absolute path and assign style of body tag of form

<body runat="server" id="BodyTag">

In your code behind, do this (C#):
I have data table with uploaded image name. I have made absolute path available for image.
String myImagePath = "../Images/Upload/"+dt_Background.Rows [0]["ImageURL"].ToString ();

BodyTag.Style.Add ("background-image", "url("+myImagePath+")");




 In body tag with image path “~/Images” is not working.









Friday 8 March 2013

How to call a Master page event handler from Content page event handler?


Introduction:

I have a master page where in I have a login panel. After registration user directly logged in into site and it will go to index page with welcome screen. So I need call master page button login event.
I have researched and there seem to be I need to call the Master page button click event handler from the content page.
In your content page, Please register master page control.
<%@ MasterType VirtualPath="~/masters/Admin.master"" %>

In you content page, add line of code to fire master page button click event.
this.Master.Btn_Login_Click(sender, e);

Registration Page:
I have user registration panel, when I register and click on “Register” button. It will redirect to index page from there I send two parameter in index page first(user name, password).
Parameter value I have sent in master page user text box and password textbox. After redirect index page with user name and password set and call login click event in master page.
  if((Request.QueryString["username"] != null
&& Request.QueryString["password"] != null))
            {
               
                TextBox txtUser = (TextBox)Master.FindControl("txt_username_emailID");
                TextBox txtPass = (TextBox)Master.FindControl("txt_password");
                txtUser.Text = Request.QueryString["username "].ToString();
                txtPass.Text = Request.QueryString["password "].ToString();              
 this.Master.btn_login_Click(sender, e);

            }