Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 21:15pm
Edited 8-Jun-11 2:10am
v3
Rate this: bad
good
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
  Permalink  
v3
Comments
beginner in C#.net at 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
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  
Comments
beginner in C#.net at 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 at 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
good
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...
  Permalink  
Comments
beginner in C#.net at 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
good
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?
  Permalink  
Comments
beginner in C#.net at 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
0 OriginalGriff 540
1 Sergey Alexandrovich Kryukov 432
2 Yogesh Kumar Tyagi 384
3 Prakriti Goyal 280
4 Maciej Los 205
0 OriginalGriff 6,472
1 Sergey Alexandrovich Kryukov 5,404
2 Maciej Los 3,434
3 Peter Leow 3,259
4 DamithSL 2,495


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 8 Jun 2011
Copyright © CodeProject, 1999-2014
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