Prince Antony G
Prince Antony G

Reputation: 932

Getting error Error-Server tags cannot contain <% ... %> constructs

<input id="tbxPopupCode" type="text" runat="server" value="<%= Request.QueryString["code"].Replace("-"," ") %>" />

I m getting an error:

Server tags cannot contain <% … %> constructs

I need to replace the value from Request.QueryString["code"] and bind into textbox value.

Upvotes: 5

Views: 14831

Answers (2)

David
David

Reputation: 3355

I know that it doesn't apply to this specific question, but I also received this error when I included the construct for an HTML tag attribute inside of a PlaceHolder control.

Upvotes: 1

user57508
user57508

Reputation:

Actually, the exception message is pretty clear: You can not have runat="server" and <%= %>.

There are some workarouns for this (eg <%# %>), but why not simply setting the value on the code-behind like this.tbxPopupCode.Value = ...?

Upvotes: 17

Related Questions