最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

asp.net - __doPostBack not rendering on postback - Stack Overflow

programmeradmin6浏览0评论

I'm having a strange problem.

I have to use GetPostBackEventRefence to force a Postback, but it works the first time, after the first postback, the .NET function is not rendered... any ideas?

This is what I'm missing after the postback:

<script language="javascript" type="text/javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
    var theform;
    if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
        theform = document.Main;
    }
    else {
        theform = document.forms["Main"];
    }
    theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
    theform.__EVENTARGUMENT.value = eventArgument;
    theform.submit();
}
// -->
</script>

I'm having a strange problem.

I have to use GetPostBackEventRefence to force a Postback, but it works the first time, after the first postback, the .NET function is not rendered... any ideas?

This is what I'm missing after the postback:

<script language="javascript" type="text/javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
    var theform;
    if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
        theform = document.Main;
    }
    else {
        theform = document.forms["Main"];
    }
    theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
    theform.__EVENTARGUMENT.value = eventArgument;
    theform.submit();
}
// -->
</script>
Share Improve this question edited May 18, 2018 at 9:10 A. AMAIDI 6,8496 gold badges36 silver badges53 bronze badges asked Sep 8, 2008 at 20:22 juanjuan 82k52 gold badges164 silver badges198 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

Well, following that idea I created a dummy function with the postbackreference, and it works... it still is weird though, because of it rendering correctly the first time

this.Page.RegisterClientScriptBlock("DUMMY", "<script language='javascript'>function dummy() { " + this.Page.GetPostBackEventReference(this) + "; } </script>");

The first thing I would look at is whether you have any asp controls (such as linkbutton, boboxes,that don't normally generate a submit but requre a postback) being displayed on the page. The __doPostback function will only be put into the page if ASP thinks that one of your controls requires it.

If you aren't using one of those you can use:

Page.ClientScript.GetPostBackClientHyperlink(controlName, "")

to add the function to your page

发布评论

评论列表(0)

  1. 暂无评论