Why do the <% =%> tags display as "& lt;% =%>"?
I have an input control on a page like this:
<input type="button" causesvalidation="false" runat="server" id="resetButton" value="Iptal" onclick='return resetForm("<%=projectValidationSummary.ClientID%>");' /> when it is displayed
<input name="ctl00$ContentPlaceHolder1$EditForm$resetButton" type="button" id="ctl00_ContentPlaceHolder1_EditForm_resetButton" value="Iptal" onclick="return resetForm("<%=projectValidationSummary.ClientID%>");" /> I use the <%=%> tags on the page, but it displays as
"<%=%>" Can someone tell me why this is happening?
<% =%> is used only within the html literal and cannot be used for the server control attribute.
Instead, you should bind the data <% #%> to us, and in your case, I think that you are trying to call the javascript function on your client side, and then your code should look like this:
<asp:button causesvalidation="false" runat="server" id="resetButton" text="Iptal" onclientclick='<%# String.Format("return resetForm(\"{0}\");", projectValidationSummary.ClientID) %>' /> and on the server side, you should associate the attribute with this code (possibly in the Page.Load event):
if(!this.IsPostBack) { this.resetButton.DataBind(); } Delete runat="server" - you do not need it if you are doing a literal record ( <%= )
So:
<input type="button" causesvalidation="false" id="resetButton" value="Iptal" onclick="return resetForm('<%= projectValidationSummary.ClientID %>');" /> Or use data binding instead:
<input type="button" causesvalidation="false" id="resetButton" runat="server" value="Iptal" onclientclick="return resetForm('<%# projectValidationSummary.ClientID %>');" /> //in code behind: resetButton.DataBind(); .Net does not like literal writing inside server rendered controls other than panels.
This may be obvious, but have you made sure the file type is appropriate? That is, jsp for JSP or ASP for ASP?
This must be caught by the compiler before coding. Is it possible that there is preprocessing before compiling the page? Your identifier has been changed and a name element has been added ...