Hi, When I am designing a web page I used some Html input controls(input type text,button etc.) in html view.I have given id,name,value fiels for these controls.And also added runat="server" attribute.Now my doubt is how can we access these controls in code behind file. For example a button name(id)=btnsubmit.For this i hav given a function name for onclick="function1()" which i wrote in code behind file.But that function is not responsing when the button was clicked.And also when i want to read or assign text for the input type text box, It is not working.What could be wrong? Please any one u help to solve this ,as it is urgent. I am not comfortable with javascript.
Thanks in advance. Kalyan.
|
| Author: ankur jain 20 Oct 2008 | Member Level: Silver | Rating: Points: 3 |
Hi, You can acess input control- text box value say name txt1 in code behind as string str = txt1.Value; And for button click in aspx page in <button> tag, write onclick="btn_Click" and use add this method in code behind.
|
| Author: Rams 01 Dec 2008 | Member Level: Silver | Rating: Points: 4 |
Hi Sharon,
After creating the HTML input button write this within the input tag onserverclick="function1" and make the text box as a server control by placing runat="server" and in the code behind add this
protected void function1(object sender, EventArgs e) { Text1.Value = "Some Value"; }
Hope this will fulfill your requirement. -Rams
|