简体   繁体   中英

OnClick doesn't work with Friendly URL

I've got a problem. I've got a button with an OnClick handler like protected void button_click(....) . The syntax is OK, but it doesn't work. When I use PostBackUrl, it works. The code in global.asax is:

Regex reg = new Regex("/***/" + result + "/(\\w+)*");
match = reg.Match(url, 0);

if (match.Groups[1].Success)
{
    s_table = result;
    s_id = match.Groups[1].Value;
    HttpContext.Current.RewritePath("~/other/***.aspx?id=" + s_id.ToLower() + "&table=" + s_table.ToLower() + "content");
    return;
}

When I click on a button with this code wired up, nothing happens. If I delete this code, the button works.

Button:

<asp:Button runat="server" OnClick="button_click"/>

Thank you, MS

您的事件函数应具有正确的参数列表,请参见此处: http : //msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.button.click.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM