Is it OK to use __doPostBack()?

前端 未结 5 1891
轻奢々
轻奢々 2020-12-17 10:25

Is it OK to use __doPostBack() or it is not recommended because it is generated from ASP.Net and we are not sure if they changed it in a next version of ASP.Net

5条回答
  •  悲&欢浪女
    2020-12-17 11:04

    We use it all over the place and I can't imagine it would ever be stripped out of ASP.NET. I think the fake/hidden button method is just as hokie if not worse. If you use the fake button approach, then you get no option to pass in the __EVENTARGUMENT. I like using __EVENTARGUMENT to pass my data to the server better than creating hidden fields, because it would be more difficult for a hacker to compromise than simply posting back some hidden field to my page. I also don't like the idea of creating fields and controls on the page if they are not even going to be displayed. I am sure that the fake button approach is probably easier for a newbie coder to understand. That being said I am searching for a more elegant way to approach this, but still find myself calling

        __doPostBack('%=UpdatePanel.ClientID%>','MyData') 
    

    in some cases.

提交回复
热议问题