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 rendered
<input
name="ctl00$ContentPlaceHolder1$EditForm$resetButton"
type="button"
id="ctl00_ContentPlaceHolder1_EditForm_resetButton"
value="Iptal"
onclick="return resetForm("<%=projectValidationSummary.ClientID%>");" />
I use <%=%>
tags on page but it is rendered as
"<%=%>"
Can anyone tell my why this is happening?
<%= %> is only usable inside literal html and can't be used on a server controls attribute.
Instead you should us databinding <%# %>, and in your case i think you are trying to trigger a 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 bind the attribute with this code (probably in the Page.Load event):
if(!this.IsPostBack)
{
this.resetButton.DataBind();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With