Click here to Skip to main content
12,635,398 members (24,876 online)
Rate this:
Please Sign up or sign in to vote.
See more: SQL-server-2005 C# ASP.NET , +
Hello Friends

I am having text box and button in masterpage.
In content page I m having gridview item.
I want to show textbox data in grodview without using querystring

Note:text box and gridview are not in same page.

Text box in masterpage.
Gridview in content page.

Is this possible.

Please help me.
Thanks in Advance.
Posted 7-Jun-11 22:15pm
Updated 8-Jun-11 3:10am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Here is the Solution

First Get the access of TextBox from MasterPage

Textbox txt1 = (TextBox)MasterPage.FindControl("txt1");

By Using this you can get value of Textbox

--> txt1.Text in Child Page

Now you can display this value inside GridView
beginner in 8-Jun-11 6:41am
its not working. i tried.. Textbox txt1=(TextBox)Master.findcontrol("txt1");
this one is coming but it didnt catch the textbox value from master page
Rate this: bad
Please Sign up or sign in to vote.

Solution 3


Try this . I am using this and it works

In your content pages page load access master pags control.

Page.Master.FindControl("Master_Page_ControlID").//Operation you want to perform. Suppose our master page text box id is txt_masterpage

and you want to take text of this textbox then you can write as

string str_result = Page.Master.FindControl("txt_masterpage").Text;

Hope this will help you.
beginner in 8-Jun-11 7:58am
its not working i tried..
string str_result=Page.Master.FindControl("tst").Text;
in that .Text is not working
i coudnt find that value
Vivek Deshmukh 8-Jun-11 8:27am
Then try

TextBox txt = new TextBox();
txt = Page.Master.FindControl("txt_masterpage") as TextBox;

string str_result= txt.Text;
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

Hey Don't Use this code inside PAge_Load Event

TextBox txt = (TextBox)Master.FindControl("TextBox1");

Or Else Do One thing place one more button in content page

and inside button_Click Event Use this Code

It will work...
beginner in 9-Jun-11 2:12am
ya... its true... s it possible to use in page load..coz i want to use dis n grid view...
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Are you sure you have that the right way around?
You cannot access Content page data from the masterpage: it doesn't exist, because the master page is shared between a number of content pages, which can have wildly different content.

Do you mean access Master page controls from the content page? If so, client side or server side?
beginner in 8-Jun-11 4:07am
ya i want to get text box value in content page on button click even. the button is in master page itself.without using querystring i have to do...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 8 Jun 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100