Pass Value from Master Page to content page

Posted by Kpoudyal2010 under ASP.NET on 1/12/2012 | Points: 10 | Views : 7439 | Status : [Member] | Replies : 2
Hi,
i have master page with search textbox, what i am trying is when users search any keyword from Master page's search text box then result should be displayed in different content page,
Can anyone help me how to do pass the parameter from Master Page,
Thank you ,




Responses

Posted by: SheoNarayan on: 1/12/2012 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
I think this might not be the best implementation of the search functionality, you may keep this in User control and place it into the master page. Handle the click event in the User control and redirect to the search result page with the keyword as querystring and accordingly search result from the database based on querystring keyword value and display the result.

Something that has been implemented on this website, click on Forums, there is a search box near Forums Home link, write some keyword into search box and click Enter key.

In case you want to stick with your own implementation, you can use this.Page.Master.FindControl("textboxId") to find the TextBox of the master page to the control page and then can retrieve its value.

Hope this helps.

Thanks



Regards,
Sheo Narayan
http://www.dotnetfunda.com

Kpoudyal2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ogipansrk on: 1/13/2012 [Member] Starter | Points: 25

Up
0
Down

You can wirte the below code in Master Page ButtonSearch Click Event:
btnSearch-Click(......)
{
Session["srch"] = txtSearch.Text;
Response.Redirect("Default.aspx", true);
}

Now...
in Deafult.aspx on page load use that session.

IT IS BETTER TO CREATE A USER CONTROL.



Kpoudyal2010, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response