How i can access Text Box in query
-
Hello all, I have a Mster Page contained some control for Search:DropDownList,TextBox,Button I have another page named Search.aspx i don't know how i can access the textbox in query: switch((Master.FindControl("DropDownList1") as DropDownList).SelectedValue) { case "Title": DataList1.DataSource = SqlDataSource1; break; . . . } my sqldatasource1 :select * from table where title=myTextbox.text but i don't know how i can access to this textbox that placed in master page. i don't know this work for Searching is true or no,if it's false i be glad for your saying. Thank you,
Hoda
-
Hello all, I have a Mster Page contained some control for Search:DropDownList,TextBox,Button I have another page named Search.aspx i don't know how i can access the textbox in query: switch((Master.FindControl("DropDownList1") as DropDownList).SelectedValue) { case "Title": DataList1.DataSource = SqlDataSource1; break; . . . } my sqldatasource1 :select * from table where title=myTextbox.text but i don't know how i can access to this textbox that placed in master page. i don't know this work for Searching is true or no,if it's false i be glad for your saying. Thank you,
Hoda
The way I'd do it is this: write a base class for all your pages. Add a property there that returns your specific Master page class, not the generic class you get from the base page. To the master page, add a public propery to get the text from the textbox. FindControl is just nastiness, why go searching when you can specify where it is ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Hello all, I have a Mster Page contained some control for Search:DropDownList,TextBox,Button I have another page named Search.aspx i don't know how i can access the textbox in query: switch((Master.FindControl("DropDownList1") as DropDownList).SelectedValue) { case "Title": DataList1.DataSource = SqlDataSource1; break; . . . } my sqldatasource1 :select * from table where title=myTextbox.text but i don't know how i can access to this textbox that placed in master page. i don't know this work for Searching is true or no,if it's false i be glad for your saying. Thank you,
Hoda
add this direcvtive in html ]]> and you can access the master pages text box like MasterPage pg = new MasterPage(); TextBox tb = (TextBox)pg.FindControl("Text1"); :laugh: