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);

            }



No comments:

Post a Comment