ASP.NET OnClick event compilation error
I'm modifying nopCommerce internet shopping software and I've a strange looking compilation error..
in file : CheckoutShipping.aspx I have:
<div class="button">
<asp:Button runat="server" ID="btnNextStep" Text="<% $NopResources:Checkout.NextButton %>"
CssClass="newaddressnextstepbutton" ValidationGroup="EnterAddress" OnClick="btnA"/&g开发者_StackOverflow社区t;
</div>
and in CheckoutShipping.aspx.cs :
protected void btnA(object sender, EventArgs e)
{
if (Page.IsValid)
{
ctrlCheckoutBillingAddress.SelectCurrentAddress();
ctrlCheckoutShippingAddress.SelectCurrentAddress();
if (!this.OnePageCheckout)
Response.Redirect("~/checkoutshippingmethod.aspx");
}
}
I get:
Compiler Error Message: CS1061: 'ASP.checkoutshippingaddress_aspx' does not contain a definition for 'btnA' and no extension method 'btnA' accepting a first argument of type 'ASP.checkoutshippingaddress_aspx' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 28: Line 29: Line 30:
" Line 31: CssClass="newaddressnextstepbutton" ValidationGroup="EnterAddress" OnClick="btnA"/> Line 32:
I've double checked the if class name & code file in aspx and aspx.cs files match(and they do).
Removing the OnClick part of the button declaration in aspx file (or changing it to ie. OnClick="Page_Load") helps.
What might be the reason for this? Do I have to register my functions somewhere?
I had the same error...
The inherit="" matched the filename, tried to change the properties of button from OnClick to OnClientClick.. and vice versa nothing worked..
The simple solution which worked for me was, changing the CodeBehind to CodeFile...
Remove event name using property window and addit again that would help some times or just remove it and addit with a defferent name I hope that would works
So as it still has happend
try to do it programatically I mean remove the event from htmls and add it in your page load
protected void Page_Load(object sender, EventArgs e)
{
...
btnA.Click += new EventHandler(btnA_Click);
...
}
void btnA_Click(object sender, EventArgs e)
{
//you stuff here//
}
Hope it works :)
精彩评论