Wednesday, March 28, 2012

Linkbutton inside update panel not working and causing exception

I page that contains an update panel. this page has a linkbutton that redirects to a new page and opens that page in a a new window(the page redirected to displays a picture). This linkbutton has been working all along with after adding this line of code in the pageload event.

ScriptManager.GetCurrent(Page).RegisterPostBackControl(LinkButton23)

suddenly, the linkbutton can nolonger redirect to the page when clicked and iam not aware of anything i did that may have crewed it up. I now get the following error message when i click it.

sys.webforms.webrequestmanagerParsererrorException: The message recieved from the server could not be parsed . Common causes for this error are when the response is modified by calls to response.write(), response.filters or server trace is enabled. Details: Error parsing near '<script language="ja'.

Actually i have noticed very strange behaviours by my IDE since i installed windows updates on tuesday, things like button click events not firing.

Any help.

Iam not sure if this extra information may help me get a reply. After some googling, most results are pointing to some thing to do with response.write in an update panel.

And in side the click event of my linkbutton, i have these javascript lines of code

ProtectedSub LinkButton23_Click1(ByVal senderAsObject,ByVal eAs System.EventArgs)

Dim myScriptAsString ="<script language=""javascript"">window.open('human Resources/viewer.aspx?id=" + employeenumber.SelectedValue +"') </" +"script>"

Response.Write(myScript)

EndSub

Iam not sure if this could be the cause of the problem but just in case.


<%@.PageLanguage="VB"AutoEventWireup="false" %>

I just changedAutoEventWireup from ="false" to="true" and every thing is back to normal, makes look stupid after wasting loosing over 8 hours. One more gotcha learnt though.

No comments:

Post a Comment