Click here to Skip to main content
15,909,530 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
ASP.NET
<asp:TextBox runat="server" ID="title"></asp:TextBox>


C#
string input_title = title.text;


when i alert the input_title ,its empty.why?

What I have tried:

if (Request.Params["input_title"] != null) r_title = Request.Params["input_title"];

this method also fail get user input.
Posted
Updated 21-Jun-16 0:16am
Comments
Sinisa Hajnal 21-Jun-16 3:41am    
Is the textbox in master page or content page?
KyLim0211 21-Jun-16 3:42am    
content
F-ES Sitecore 21-Jun-16 5:29am    
You need to clarify where your code is, ie is the textbox on the master or content and are you trying to access the textbox from the master or content, as these things matter. Anyway, this link will show you how to access controls on the content from the master and vice versa.

http://forums.asp.net/t/1963903.aspx?Finding+controls

1 solution

If your
ASP.NET
<asp:TextBox runat="server" ID="title"></asp:TextBox>


is in Master Page, you can access data in cs file (code behind) of master.

Example : title.Text

Otherwise you can access it via javascript or jquery

Using Jquery

$('#textboxId').val()

Using Javascript

document.getElementById("textboxId").value
 
Share this answer
 

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