简体   繁体   中英

Access variable in aspx.cs file and display in text box

Here is my Emial.Aspx.cs file. I have a public variable called loginEmail.

public String loginEmail;

protected void Page_Load(object sender, EventArgs e){
loginEmail= Session["Email"].ToString();
}

I want to display that variable in bellow textbox. But this is not worked for me.

<td>
   <asp:TextBox ID="TextBox_name" runat="server" Text = "<%= loginEmail %>";></asp:TextBox>
</td>

Error:

Parser Error Message: Server tags cannot contain <% ... %> constructs.

Please help me.

在页面加载事件中

TextBox_name.Text = loginEmail;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM