ASP.NET _doPostBack从Javascript [英] ASP.NET _doPostBack from Javascript
本文介绍了ASP.NET _doPostBack从Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
后续code没有在IE浏览器:
<脚本类型=文/ JavaScript的SRC =JS / jQuery的-1.4.2.min.js>< / SCRIPT>
<脚本类型=文/ JavaScript的>
$(函数(){
$(:文[ID * = txtPopCEP])键preSS(函数(五){。
VAR tecla =(e.which)? e.which:e.key code;
如果(tecla == 13)
{
__doPostBack('ctl00 $ ContentPlaceHolder1 $ ImageButton1',''); }
});
});
< / SCRIPT>
这doenst致电doPostBack function.But在FF它工作...任何ideias?
ImageButton1 code输出:
<输入类型=形象NAME =$ ctl00 $ ContentPlaceHolder1 ImageButton1ID =ctl00_ContentPlaceHolder1_ImageButton1SRC =imagens / btCEP.jpg的风格=BORDER-宽度: 0像素; />
解决方案
__ doPostBack
不直接与图像和按钮的工作。添加的onclick
到 aspx.cs
页。结果
对于低于code intance检查:
脚本=JavaScript的:返回popUpCalendar(这一点,+ txtEndDate.ClientID + @,'+ DateTime.Today.ToString(MM / DD / YYYY)+ @ ','+ EstartDate + @,+ EendDate + @','MM / DD / YYYY','__doPostBack(\\'+ txtStartDate.ClientID + @\\'),');
imgEndDate.Attributes.Add(onclick事件,脚本);
希望这会工作。
The follow code does not work in IE:
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function(){
$(":text[id*=txtPopCEP]").keypress(function(e){
var tecla = (e.which) ? e.which : e.keycode;
if(tecla == 13)
{
__doPostBack('ctl00$ContentPlaceHolder1$ImageButton1', '');
}
});
});
</script>
It doenst call the doPostBack function.But in FF it works...Any ideias?
ImageButton1 code output:
<input type="image" name="ctl00$ContentPlaceHolder1$ImageButton1" id="ctl00_ContentPlaceHolder1_ImageButton1" src="imagens/btCEP.jpg" style="border-width:0px;" />
解决方案
__doPostBack
dont work directly with image and buttons. Add the onclick
through aspx.cs
page.
For intance check below code:
script = "javascript:return popUpCalendar(this," + txtEndDate.ClientID + @",'" + DateTime.Today.ToString("MM/dd/yyyy") + @"','" + EstartDate + @"','" + EendDate + @"', 'mm/dd/yyyy', '__doPostBack(\'" + txtStartDate.ClientID + @"\'),')";
imgEndDate.Attributes.Add("onclick", script);
Hope this will work.
这篇关于ASP.NET _doPostBack从Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文