Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
153 views
in Technique[技术] by (71.8m points)

asp.net - asp:linkbutton not functioning in production

I've got an asp:linkbutton as follows:

<asp:LinkButton ID="lb_new" runat="server" ForeColor="White">New Item</asp:LinkButton>

Protected Sub lb_new_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lb_new.Click
    ViewState("ItemID") = "0"
    Dim myURL As String
    myURL = String.Format("D002.aspx?e={0}&i={1}", ViewState("EventID"), ViewState("ItemID"))
    Response.Redirect(myURL)
End Sub

Up until recently, it has functioned as it should. But for some reason, it has stopped working in production. As far as I can tell, it's not connecting to it's code-behind at all (I tried modifying it to simply change the text in one of the text boxes ont he page, and it fails that as well). Still works if I run the website through visual studio. But as soon I publish to our production server, it no longer works.

I'm stumped -- and still fiddling with it.

If anyone has experienced this, please share. Have been on this for a couple hours now, and am out of ideas.

Thank you!

UPDATE

  1. The event handler has been suggested as missing by a couple of folks. This is actually handled in the code-behind by the 'Handles' clause (...Handles lb_new.Click).
  2. Manually deleted the items in the production folder, then re-published. No joy.
  3. Verified the files in the production folder are the new ones.
  4. I created a brand new linkbutton -- it fails to connect to it's code-behind as well
  5. I added an Onclick= to the mark-up. This shouldn't be necessary, considering the Handles clause in the code-behind. Regardless, the click still fails.

...still plugging away at it

UPDATE2

Removed the required field validators on the page, and it works. This does not make sense to me, because I had other controls on the page causing postbacks, and they still worked the whole time. Also, I had the fields that were being validated filled-in, so no reason (I can think of) that the validators would have been preventing the postback.

Now I just have to figure out how to do validation on the page without the required field validators.

...confused... :-)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Check the __EVENTTARGET and __EVENTARGUMENT variables on the post; these should match the values from the button that triggered the postback. That's at least the first clue...

Did you upgrade some third party DLL or upgrade from .NET 3.5 to .NET 4.0 or something like tha too?

HTH.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...