我有一个表单,里面有若干属性必须符合某种规则(如产品编码、规格等),因此将对应的TextBox设置为 ReadOnly="True",用户不能直接填写,点击这些文本框时弹出个子窗口,在子窗口里选择好某个产品,再将产品名称、规格、编码等属性刷新回父窗口里的表单。
可是,回到父窗口进行任何操作时,只要是有刷新动作的事件,这些属性ReadOnly="True"的TextBox都会被立即清空。也就是说,这些TextBox里的值我根本没法进行保存。我用的是C#2005.
用C#2003没有上述问题,但又必须用2005来做。
请高手指点。
可是,回到父窗口进行任何操作时,只要是有刷新动作的事件,这些属性ReadOnly="True"的TextBox都会被立即清空。也就是说,这些TextBox里的值我根本没法进行保存。我用的是C#2005.
用C#2003没有上述问题,但又必须用2005来做。
请高手指点。
我尝试把子页面的值传回到父页面的Label上面,可是不行。
写法如下:
Response.Write("<script>self.opener.document.all('ProtCode"+i+"').value='" + ProtValue[i]+ "'</script>");
ProtCode[i]就是父页面上面的某个控件,如果是TextBox,能刷回去,Label就不行。
不知我的写法有无问题。
function Select_Product()
{
window.open("product.aspx","","");
} function SetProduct_Name(Product_ID,Product_Name)
{
document.getElementById("txtProductName").value = Product_Name;
document.getElementById("hfProductID").value = Product_ID;
}
product.aspx
点击产品时:
function Select(Product_ID,Product_Name)
{
if(Product_ID && Product_Name)
{
if(window.opener && window.opener.SetProduct_Name)
{
window.opener.SetProduct_Name(Product_ID,Product_Name)//将得到的值传回父页
window.close()
}
}
}
子页面选择某产品之后,相关的各值是完全成功地传回到父页面了的。
每个TextBox都可以清楚看到传回来的值。我的问题是:
这些已经传回来的值,在我点击页面上某个控件时,比如“保存”按钮,各个属性为ReadOnly="True"的Textbox里面的内容就统统没有了。
但在C#2003情况下,这种情况不会发生。
Response.Write(" <script>self.opener.document.all('ProtCode"+i+"').value='" + ProtValue[i]+ "' </script>");
现在改写成:
Response.Write(" <script>window.opener.document.getElementById('ProtCode"+i+"').value='" + ProtValue[i]+ "' </script>"); 这样就能把值传回到Label了,达到了防止用户改写的目的。分太少,请接。