VB.NET - Javascript DoPostBack - Asked By Henry Taylor on 07-May-12 03:03 PM

Earn up to 20 extra points for answering this tough question.
We have upgraded a very old application to Framework 4.0 using VS2010.  We have a problem with link buttons.  On some machines hovering over the link yields a task bar message that reads:

javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("cmdAppQuote", "", true, "", "", false, true))

and everything works fine BUT on some machines the task bar message reads:

javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(  << It gets cutoff.  

I have swapped out the pages from a machine where it works to one where it doesn't work but the javascript still gets cutoff.

Clicking the link gives an ambiguous syntax error like char 1 line 59.

Does any one know why this is happening?

Thanks.

PS - I looked at the page source and the entire line is there.  strange.
Jitendra Faye replied to Henry Taylor on 08-May-12 12:14 AM
It is better to trace your Javascript code  using Javascript debugger.

Or use Fire bug to debug your code, Here you can see which line is generating error.
Sreekumar P replied to Henry Taylor on 08-May-12 08:11 AM
Hi,
I strongly believe that the problem is with the Rendering problem.
The problem might be with escaping of Double quotes(") or Single Quotes(') chars

So what I can give a solution like,

Remove the OnClick event (event wire).

<asp:LinkButton ID="lnkInsert" runat="server" Text="Insert" OnClick="lnkInsert_Click" />


And we will give the event or javascript directly from code.

from PageLoad or somewhere,

lnkInsert.Attributes["href"] = "javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('"+ cmdAppQuote.ClientID +"', '', true, '', '', false, true))";

also try this too.

lnkInsert.Attributes["href"] = "javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(\"" + cmdAppQuote.ClientID + "\", \"\", true, \"\", \"\", false, true))";




please mark helpful if it seems to be that
by,
Sreekumar P
Henry Taylor replied to Sreekumar P on 08-May-12 10:49 AM
Here is what fixed the problem:

web.config

<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" autoEventWireup="true" enableSessionState="true" enableViewState="true" enableViewStateMac="true" smartNavigation="true" validateRequest="false" />

The reason the javascript was getting cutoff is because the string representing the js started with a double quote and when we got to the first argument it was encapsulated in a double quote.  This terminated the string.

I don't know the mechanics of why this fixed the problem but then again I don't know many things that happen behind the scenes with computers.  If I know something works I do it with out needing to know exactly why.  Parts is parts!
Sreekumar P replied to Henry Taylor on 08-May-12 10:53 AM
Great !! ..

Ya... that was the problem... I have not done a research on how to stop that... :)
Hope my reply helps u some...
[)ia6l0 iii replied to Henry Taylor on 09-May-12 10:57 AM
Instead of doing changes to all pages, 

<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" autoEventWireup="true" enableSessionState="true" enableViewState="true" enableViewStateMac="true" smartNavigation="true" validateRequest="false" /> 


I would rather choose to turn off validation on the link buttons alone.
<asp:Linkbutton ....."CausesValidation=False" />

And also, replace any double quotes inside the attributes of the linkbutton, or simply escape them. 

Hope this helps.