日期:2014-05-18  浏览次数:20829 次

javascript里的_doPostBack('LinkButton1','')问题?
在javascript函数里调用_doPostBack( 'LinkButton1 ', ' '),不能触发cs文件里的相应函数?
aspx:
<script   language= "javascript ">
        function   Getsort(obj)
        {
    document.all.sortfield.value=obj;
if(document.all.sortstring.value== 'ASC ')
document.all.sortstring.value= 'DESC ';
else   if(document.all.sortstring.value== 'DESC ')
document.all.sortstring.value= 'ASC ';

_doPostBack( 'LinkButton1 ', ' ');
      }
    </script>

cs:
private   void   LinkButton1_Click(Object   Sender,   System.EventArgs   e)
{
string   sortstring=Request.Form[ "sortstring "].ToString();
string   sortfield=Request.Form[ "sortfield "].ToString();
string   fullsortstring=sortstring+ "   "+sortfield;
if(fullsortstring!= " "&&fullsortstring!=null)
BindDataSource(fullsortstring);

}

------解决方案--------------------
在CS里重新注册一下JS
Ajax.Utility.RegisterTypeForAjax(typeof(_doPostBack));
------解决方案--------------------
_doPostBack( 'LinkButton1 ', ' ');
第二个参数应该是你CS文件中的LinkButton1_Click事件
_doPostBack( 'LinkButton1 ', 'LinkButton1_Click ');

------解决方案--------------------
_doPostBack
前面是两个下划线
__doPostBack
------解决方案--------------------
双击事件?
LinkButton1只能执行单击事件啊
------解决方案--------------------
zwwlovezy1()
_doPostBack( 'LinkButton1 ', ' ');
第二个参数应该是你CS文件中的LinkButton1_Click事件
_doPostBack( 'LinkButton1 ', 'LinkButton1_Click ');

以上为正解!!!lz请注意!
------解决方案--------------------
_doPostBack
前面是两个下划线
__doPostBack

------解决方案--------------------
哦,刚回复错了,正解是_doPostBack前面是两个下划线:__doPostBack,而其第二个参数你可以用来传递到后台的,例如:
js:
var value = "add ";
__doPostBack( "btn1 ",value);

cs:
private void btn1_Click(object sender, System.EventArgs e)
{
string opt = Request.Form[ "__EVENTARGUMENT "];
if(opt== "add ")
{
//do something yourself here
}
}
------解决方案--------------------

但你 HTML里写的是双击事件 不知道放个linkbutton行不行
------解决方案--------------------
<script language= "javascript ">
function Getsort(obj)
{
document.all.sortfield.value=obj;
if(document.all.sortstring.value== 'ASC ')
document.all.sortstring.value= 'DESC ';
else if(document.all.sortstring.value== 'DESC ')
document.all.sortstring.value= 'ASC ';

<%=Page.GetPostBackClientEvent(this. 'LinkButton1 ', " ")%>
}
</script>
这样由服务器自动产生__doPostBack方法


------解决方案--------------------
(1.) <asp:LinkButton ID= "LinkButton1 " Runat=server> </asp:LinkButton>