Cliff,
Since your textboxes are not inside one of the data bound controls
(GridView, FormView, etc.), you'll need to call Page.BindData() explicitly
and cannot use the Eval()/Bind() functions.
Change your aspx to:
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Me.em %>'></asp:TextBox>
Then in your codebehind call Page.DataBind():
.....
Protected em As String = ""
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Me.em = "Data binded on " & DateTime.Now.ToLongTimeString()
Page.DataBind()
End Sub
see also:
http://msdn2.microsoft.com/en-us/library/bda9bbfx.aspx
Hope this helps,
Jason Vermillion
"Cliff" wrote:
Hi,
i would like to get the value of variable 'em', defined in code-behind, into
a textbox.
I tried two ways but withoit succes (no error).
The first textbox is empty, the second gets:<%=em %>
aspx file:
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server" Text='<%# eval(em)
%>'></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Text="<%=em
%>"></asp:TextBox>
</form>
code-behind:
Friend em As String
em = "ok"
Thanks
Cliff