asp.net DROPDOWNLIST有条件回传 [英] asp.net Dropdownlist conditional postback
问题描述
我有一个DropDownList,并有一个事件的SelectedIndexChanged这postsback,我希望能够表现出一个消息时,他改变的DropDownList值用户的基础上,从信息输入,如果我不得不回传我会决定还是不行。
表示将你确定的消息?如果他选择是的,我将继续与回传,如果他说没有,我会取消,回传和选择分配previous值。
我已经搜索了很多,但无法弄清楚解决这个,我想如果有一个SCRIPT关闭决定是否需要或不回传,可以帮助我猜
感谢
//获取到的DropDownList参考
变种selectlistId ='&下;%= ddlYourList.ClientID%GT;',
选择列表=的document.getElementById(selectlistId);//附加到onchange事件
selectlist.onchange =功能(){ //决定是否执行__doPostBack事件,该事件提交
//形式回服务器
如果(确认(你确定要这么做吗?)){
__doPostBack(selectlistId,'');
}
};
I have a dropdownlist and have an event selectedIndexChanged which postsback, i want to be able to show a message to the user whenever he changes the value in dropdownlist, based on the input from the message i will decide if i have to postback or not.
The message shown would be are you sure? if he selects yes i would continue with postback, if he says no, i would cancel the postback and assign the previous value as selected.
I have searched alot but cant figure out a solution to this, i think if there is a javascipt function which determines if a postback is required or not that could help i guess
Thanks
// get a reference to the DropDownList
var selectlistId = '<%= ddlYourList.ClientID %>',
selectlist = document.getElementById(selectlistId);
// attach to the onchange event
selectlist.onchange = function() {
// decide whether to execute the __doPostBack event, which submits the
// form back to the server
if(confirm("Are you sure you want to do this?")){
__doPostBack(selectlistId, '');
}
};
这篇关于asp.net DROPDOWNLIST有条件回传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!