Passing variable from code behind to HTML tag in ASP.NET
February 8, 2012 3 Comments
Some how in some case, we want to directly passing variable that we already declare in ASP.NET with code behind to the HTML tag, like <input type = “TEXT”> tag in HTML, we can do that just with the simple code, here is the way:
Declare test as a property (at the class level) instead of a local variable, then refer to it as you currently do in your markup (aspx).
VB.NET 10 (automatic properties):
Protected Property test As String = "Test"---------------------------------------------
Pre-VB.NET 10 (no support for automatic properties)
Private _test As String
Protected Property Test As String
Get
Return _test
End Get
Set(value As String)
_test = value
End Set
End Property
——————————————————–
place that variable in HTML tag that you want to place, such as :
<input type=”TEXT” name=”SomeThing” size=”50″ maxlength=”250″ value = “<%= test %>”>
that’s all, hope this helpful
I just want to tell you that I am new to blogs and truly loved this website. Most likely I’m going to bookmark your blog post . You surely have perfect stories. Thanks a lot
Thank you so much
you are welcome ^_^