brad
brad

Reputation: 687

WebForm_DoPostBackWithOptions is not defined using chrome

On one of my pages, my dynamic links work fine in IE10 but do not work in either Chrome or via Explorer on my Windows phone. In Chrome I get the "WebForm_DoPostBackWithOptions is not defined" when I try to click on any of the dynamic links. I've done a lot of research, and have tried to modify the settings for the ISAPI filters in the Handler Mappings in IIS 8, but that didn't work. Please help. I'm stumped.

Update: This also does not work in Firefox. It seems the dynamic links on this page work only in IE10. The links are being generated from my codebehind. The strange this is that on the other pages the links are generated differently with the javascript on the href being different, yet I'm creating the anchors in the codebehind exactly the same way.

Here's code for a "bad" anchor:

    Dim anchName As New HtmlAnchor
anchName.ID = "bcrasodiuhf" & foo
AddHandler anchName.ServerClick, AddressOf HandleNameClick
anchName.Attributes.Add("style", "font-weight: bold; font-size: 14px;")
anchName.Attributes.Add("for", foo)
anchName.InnerText = foo

And the "bad" result:

<a id="MainContent_bcrasodiuhf1" **href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBac…0$MainContent$bcrasodiuhf1", "", true, "", "", false, true))**" for="1" style="font-weight: bold; font-size: 14px;"></a>

Here is a "working" anchor:

    Dim ancJoe As New HtmlAnchor
    ancJoe.ID = "pjancJoe" & foo
    AddHandler ancJoe.ServerClick, AddressOf HandleJoeClick
    ancJoe.InnerText = joe.Title
    ancJoe.Attributes.Add("style", "font-size: 150%;")
    ancJoe.Attributes.Add("jn", foo)
    ancJoe.Attributes.Add("for", foo)
    ancJoe.Attributes.Add("action", "actionA")  

And the "working" result:

<a id="MainContent_pcancJoe19416" **href="javascript:__doPostBack('ctl00$MainContent$pcancJoe19416','')"** action="actionA" for="194" jn="foo foo" forc="16" style="font-size: 150%;"></a>

Upvotes: 22

Views: 12803

Answers (4)

Augis
Augis

Reputation: 1963

Try to set causesValidation=false for the button

Upvotes: 1

sino
sino

Reputation: 776

I had (almost ) same problem , and it was fixed by reinstalling .Net Framework on the IIS

Upvotes: 0

Varinder Singh
Varinder Singh

Reputation: 1600

There is a bug in the browser definition files that shipped with .NET 2.0 and .NET 4, namely that they contain definitions for a certain range of browser versions. But the versions for some browsers (like IE 10) aren't within those ranges any more. Therefore, ASP.NET sees them as unknown browsers and defaults to a down-level definition, which has certain inconveniences, like that it does not support features like JavaScript.

Fortunately,A hotfix is available for .NET Framework 4.0

https://support.microsoft.com/en-gb/kb/2600088

You can read more about this issue on Scott Hansellman's blog

http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx

Upvotes: 0

user2772146
user2772146

Reputation: 36

The respective JS code (i.e. WebForm_DoPostBackWithOptions(options)) is a built-in part and is linked dynamically. A proper URL is being generated by ScriptManager of the page.

Considering you've mentioned you're using URL Rewrite, try checking whether URLs like WebResource.axd?d=XXX are not being ignored/re-wrote.

Also, it might worth to look at IIS Handlers Mapping configuration to ensure .axd resources are mapped to the standard ISAPI module handler.

Upvotes: 2

Related Questions