devan
devan

Reputation: 1653

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.

Upvotes: 0

Views: 3200

Answers (1)

Symeon Breen
Symeon Breen

Reputation: 1541

In the page Load event

TextBox_name.Text = loginEmail;

Upvotes: 4

Related Questions