简体   繁体   中英

LinkButton OnClick working on local IIS but not on remote server

On a page I have DropDownList and a LinkButton with the following code:

<asp:LinkButton ID="linkButton1" OnClick="FormSubmit" Text="CLICK ME" runat="server" />

Code behind:

protected void FormSubmit(object sender, EventArgs e)
{
    Response.Redirect("/location.aspx?dropDownValue=" + this.dropDownList.SelectedValue);
}

The purpose of which is for the user to select a value from the drop down list and be forwarded to a new page with a query string relating to that value.

On my local IIS this works find and redirects to localhost/location.aspx with the appropriate query string, however, on the remote server all that happens is that the page refreshes.

We've recently had a server outage and some settings on the server (eg firewall) have changed which may have thrown this out, but I cannot confirm for definite whether this is a problem that existed before.

So the question is: what would cause this difference in behaviour between my local IIS and the remote IIS?


Some more details:

Both are IIS 7 running .NETv2

I have tried https://stackoverflow.com/a/13498195/1185053 and https://stackoverflow.com/a/1953651/1185053

Check the ViewState . I observed the same thing recently. I had code with a link in a GridView which was working, but after merging with master pages I couldn't execute LinkButton server code. It had lost binding.

There is another case. My Visual Studio behaves weirdly sometimes. After I double click in design view it creates another event as linkbutton1_click in code behind.

So after activating `ViewState' / double clicking the linkbutton once I was able to bind the code behind event properly.

Hope it helps.

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