这段代码让我感到震惊。看起来很简单,但我得不到正确的结果。 [英] This code is shaking me. Looks simple but I don't get correct result.

查看:33
本文介绍了这段代码让我感到震惊。看起来很简单,但我得不到正确的结果。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我使用JS将一个aspx页面转换为popup,但就像之前textfields不再显示数据一样,plzz help.here是代码



JS code 4 popup :



  function  basicPopup(){
// var imageCode ='<%= imageCode%>';


var imageCode = document .getElementById(' holdValue');
popupWindow = window .open( ImageUpload .aspx?imageCode = + imageCode,' popUpWindow'' height = 300,width = 600,left = 100,top = 30,resizable = No,scrollbars = No,toolbar = no,menubar = no,location = no,directories = no,status = No');
// popupWindow = window.open(ImageUpload.aspx,'popUpWindow','height = 300 ,width = 600,left = 100,top = 30,resizable = No,scrollbars = No,toolbar = no,menubar = no,location = no,directories = no,status = No');


}













这里imagecode是用于获取data的字符串。我想在按钮的ONclick上显示dta和弹出窗口。这是我的按钮代码

  protected   void  btnUpload_Click( object  sender,EventArgs e)
{

Response.Redirect( ImageUpload.aspx?imageCode = + this .SelectedItem.ImageCode);


}

解决方案

代码中的逻辑看起来不正确



在按钮上单击,您将URL重定向到ImageUpload.aspx?imageCode = 10(假设ID为10),这对javascript /函数<$知之甚少要调用p $ p> basicPopup()

。所以很明显javascript不会被调用



1.你必须修改按钮才能知道按钮上的javascript要点击



< asp:Button ID =Button1runat =serveronClientClick =basicPopup(); Text =Button/> 

这行代码表示在buttn上单击要调用的javascript





2.现在继续并定义你的javascript



 <  < span class =code-leadattribute> script     type   =  text / javascript >  
function basicPopup( ){



var imageCode = document.getElementById('holdValue');
popupWindow = window.open(ImageUpload.aspx?imageCode = 1,'popUpWindow','height = 300,width = 600,left = 100,top = 30,resizable = No,scrollbars = No,toolbar = no,menubar = no,location = no,directories = no,status = No');
// popupWindow = window.open(ImageUpload.aspx,'popUpWindow','height = 300,width = 600,left = 100,top = 30,resizable = No,scrollbars = No,toolbar = no ,menubar = no,location = no,directories = no,status = No');


}
< / script < span class =code-keyword>>







这应该有效< br $>




唯一的共鸣,它可能无效是你的javascript部分在错误的地方。如果不起作用请告诉我您已定义Javascript的区域描述


也许可以尝试

 popupWindow = < span class =code-sdkkeyword> window  .open(  ImageUpload.aspx?imageCode = + imageCode +  ,'popUpWindow',height = 300,width = 600,left = 100,top = 30 ,resizable =否,scrollbars = No,toolbar = no,menubar = no,location = no,directories = no,status = No); 


actually i converted an aspx page to popup using JS ,but like before the textfields doesnot shows data anymore,plzz help.here are codes

JS code 4 popup:

function basicPopup() {
             //var imageCode = '<%=imageCode%>';


             var imageCode = document.getElementById('holdValue');
             popupWindow = window.open("ImageUpload.aspx?imageCode="+ imageCode  , 'popUpWindow', 'height=300,width=600,left=100,top=30,resizable=No,scrollbars=No,toolbar=no,menubar=no,location=no,directories=no, status=No');
             //popupWindow = window.open("ImageUpload.aspx" , 'popUpWindow', 'height=300,width=600,left=100,top=30,resizable=No,scrollbars=No,toolbar=no,menubar=no,location=no,directories=no, status=No');


         }







here imagecode is string used to fetch data.i want to show dta and pop up window on ONclick of button.here is my button code

protected void btnUpload_Click(object sender, EventArgs e)
{

Response.Redirect("ImageUpload.aspx?imageCode=" + this.SelectedItem.ImageCode);


}

解决方案

The logic in your code does not look right

On the button click you are redirecting the url to ImageUpload.aspx?imageCode=10 (assume the ID as 10) and this does not know anything about the javascript / the function

basicPopup()

to be called. so obviously the javascript would not get called

1. you have to amend the button so that it know that the javascript to be called on the button click

<asp:Button ID="Button1" runat="server" onClientClick="basicPopup();" Text="Button" />

This line of code says that on the buttn click the javascript to be called


2. Now move on and define your javascript

<script type="text/javascript">
           function basicPopup() {



               var imageCode = document.getElementById('holdValue');
               popupWindow = window.open("ImageUpload.aspx?imageCode=1", 'popUpWindow', 'height=300,width=600,left=100,top=30,resizable=No,scrollbars=No,toolbar=no,menubar=no,location=no,directories=no, status=No');
               //popupWindow = window.open("ImageUpload.aspx" , 'popUpWindow', 'height=300,width=600,left=100,top=30,resizable=No,scrollbars=No,toolbar=no,menubar=no,location=no,directories=no, status=No');


           }
       </script>




This should work


The only reson, it may not work is that you have your javascript section in a wrong place. If does not work let me know with the description of area where you have defined your Javascript


Maybe try

popupWindow = window.open("ImageUpload.aspx?imageCode="+ imageCode+", 'popUpWindow', height=300,width=600,left=100,top=30,resizable=No,scrollbars=No,toolbar=no,menubar=no,location=no,directories=no, status=No");


这篇关于这段代码让我感到震惊。看起来很简单,但我得不到正确的结果。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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