javascript在回发后无法正常工作 [英] javascript not working after postback

查看:104
本文介绍了javascript在回发后无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Web应用程序iam中,使用以下javascript代码将弹出窗口中的值设置为主窗口.
设置列表框中的值[弹出窗口]

In my web application iam using the following javascript code for to set the values in pop up window to main window.
To set the values in list box[PopUp Window]

var  frm_bank = document.forms[''form1''].elements;
var ind = frm_bank[''lst_bankname''].selectedIndex;
var  b_code = frm_bank[''lst_bankname''].options[ind].value;
var  bankname=frm_bank[''lst_bankname''].options[ind].text;



并将此值分配给下拉列表[主窗口],使用了以下代码



and to assign this values to dropdown list[Main Window] the following code is used

window.opener.document.getElementById(''ctl00_ContentPlaceHolder1_ddl_bankcode'').options[0].value =b_code;
window.opener.document.getElementById(''ctl00_ContentPlaceHolder1_ddl_bankcode'').options[0].text =bankname;


并且以下代码用于调用下拉列表的SelectedIndexChanged事件


and the following code is used to call the SelectedIndexChanged event of dropdown list

window.opener.document.getElementById(''ctl00_ContentPlaceHolder1_ddl_bankcode'').onchange();



第一次可以正常使用.回发后无法使用.如果代码



It is working fine for first time.after post back it is not worked.if the code

window.opener.document.getElementById(''ctl00_ContentPlaceHolder1_ddl_bankcode'').onchange();


不使用它一直都很好w.但是我也想使用它.javascript被调用并且值bankname,b_code在第二次也是正确的,但是它没有设置为dropdownlist
它有什么问题,请帮助我解决它.


is not used it works fine all the timew.but i want to work it also.javascript is called and the values bankname,b_code are correct at second time also but it is not set to dropdownlist
What is the problem with it Please help me to solve it

推荐答案

我建​​议的第一件事是开始使用JQuery,而不是像现在这样手动编码.您可以使用CSS选择器来访问元素,而无需使用ASP.NET混乱的名称来确保获得正确的元素. jQuery还具有更好的机制来连接事件.
The first thing I would recommend is start using JQuery rather than hand coding it as you are. You can use CSS selectors to access the elements without the need for the ASP.NET mangled names to ensure you are getting the correct element. JQuery also has a better mechanism to hookup events.


这篇关于javascript在回发后无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆