__doPostBack is not defined

2019-01-18 01:46发布

Im getting that error when try to call a __doPostBack on one of my pages, every page that i have in the project use __doPostBack function but in this particular page im getting that Javascript error.

i was looking in the internet and the only thing i read is that this error happends when i have a unclose tag but i review the site and its ok.

Error: __doPostBack is not defined Source File: htt://localhost:99/ProjectName/Disable.aspx Line: 1

25条回答
smile是对你的礼貌
2楼-- · 2019-01-18 02:33

I was getting this when I was clicking on a LinkButton. Solved this by adding OnClick="LinkButton2_Click" to the markup.

查看更多
forever°为你锁心
3楼-- · 2019-01-18 02:33
lnkDeactivate.Attributes("onclick") = ClientScript.GetPostbackClientHyperlink(lnkDeactivate, "deactivate")
查看更多
仙女界的扛把子
4楼-- · 2019-01-18 02:34
 this.Page.ClientScript.GetPostBackEventReference(<a control>, string.Empty); 

This trick worked for me. Still would have liked to know why it wasn't rendering...

Thank you!

查看更多
ら.Afraid
5楼-- · 2019-01-18 02:35

It is __doPostBack function not found error. Put one button in page and set its usersubmitbehavior=false, then run and see viewsource, you will have __doPostBack function automatically be added in your page.

Now put your own html button which you want to make postback from and call __doPostBack function by setting its onclick="__doPostBack('mybut','save')".

Now the __doPostBack function required for your html button is given by the above button.

查看更多
甜甜的少女心
6楼-- · 2019-01-18 02:37

__doPostBack() should be automatically included by any ASP.NET WebControl that could cause a post back. You sound like you are calling it manually in some Javascript you wrote. If so, you will need to include a WebControl, to make sure that function in inserted onto the page.

查看更多
狗以群分
7楼-- · 2019-01-18 02:37

The run time/client side error __doPostBack is undefined hassled me for a few hours. There was lots of misleading/incorrect help on the net. I inserted the following line of code in the Page_Load event of the default.aspx.cs file and everything worked fine, on my system and in production with GoDaddy.

ClientScript.GetPostBackEventReference(this, string.Empty);
查看更多
登录 后发表回答