Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 8-Jun-11 2:10am
v3

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
 
Share this answer
 
v3
Comments
beginner in C#.net 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
Hi,

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.
 
Share this answer
 
Comments
beginner in C#.net 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;
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...
 
Share this answer
 
Comments
beginner in C#.net 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...
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?
 
Share this answer
 
Comments
beginner in C#.net 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900