0

Suppose I have these both in my aspx file:

<asp:TextBox ID="tbASP" runat="server" Width="400px" />
<input id="tbHTML">

How to copy the content of tbHTML to tbASP from code behind?

2
  • when you want to copy i mean on on submit of button Commented Sep 12, 2013 at 5:44
  • Yes and the code is in code behind. Commented Sep 12, 2013 at 5:49

2 Answers 2

2

1.Add runat="server" to input..

<input id="tbHTML" runat="server">

you will access in code behind..

2.Else use find control

System.Web.UI.HtmlControls.HtmlInputControl tbHtml= this.FindControl("tbHtml") as System.Web.UI.HtmlControls.HtmlInputControl;
tbAsp.Text=tbHtml.value;
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Let me try this.
1

Make sure the Id of ur Input element is unique in page...than you can try like this.

tbASP.Text=Page.Request["tbHTML"].ToString();

Edit Vice Versa

  <input id="id" value=<%= TextBox1.Text %> />

2 Comments

Amit I hope you will still be able to see my reply. I just want to ask. From this approach that you provided how can I do this vise versa? I mean this time copying from asp textbox to html input element.
@ChrisN.P. glad to help u...happy coding

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.