maxp
maxp

Reputation: 25181

Inline Code in markup page in ASP.NET Webforms?

Is something similiar to the following pseduocode possible on server side controls?

<asp:Label runat="server" ID="lbl" Text=<%=DateTime.Now.ToString(); %> />

I.e. assigning attributes.

Upvotes: 1

Views: 5826

Answers (2)

jrummell
jrummell

Reputation: 43117

This will work for databound controls, e.g.

<asp:Label runat="server" ID="lbl" Text="<%# DateTime.Now.ToString() %>" />

Then in your code behind, you'll need to call lbl.DataBind().

Upvotes: 1

James Johnson
James Johnson

Reputation: 46077

Try this:

<asp:Label runat="server" ID="lbl" Text='<%=DateTime.Now.ToString()%>' /> 

Upvotes: 1

Related Questions