Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何在图像按钮中停止回发_Asp.net_Vb.net - Fatal编程技术网

Asp.net 如何在图像按钮中停止回发

Asp.net 如何在图像按钮中停止回发,asp.net,vb.net,Asp.net,Vb.net,如何避免“返回图像”按钮。我尝试了这种方法,但单击“图像”按钮时,我的文本框不显示 我的问题是->图像按钮在每次单击时都会回发。为了避免这种情况,我尝试使用java脚本,如下所示。单击按钮时,我想显示一个文本框,它在TextBox1\u TextChanged事件中有很多功能。但它不起作用 <asp:ImageButton ID="ImageButton1" runat="server" OnClientClick="return ValidNum();" onClick="Im

如何避免“返回图像”按钮。我尝试了这种方法,但单击“图像”按钮时,我的文本框不显示

我的问题是->图像按钮在每次单击时都会回发。为了避免这种情况,我尝试使用java脚本,如下所示。单击按钮时,我想显示一个文本框,它在TextBox1\u TextChanged事件中有很多功能。但它不起作用

<asp:ImageButton ID="ImageButton1" runat="server" 
    OnClientClick="return ValidNum();" onClick="ImageButton1_Click" Height="52px" 
    ImageUrl="search1.png" style="margin-right: 0px" Width="126px" />


<script>

        function ValidNum() {

            return false;

        }

</script>
编辑 现在我更改了我的代码,如下所示,但-BC30456:“return”不是“ASP”的成员。将显示“about_aspx”错误

  <asp:ImageButton ID="ImageButton1" runat="server" 
    OnClientClick="return ValidNum();" onClick="return showBox();" Height="52px" 
    ImageUrl="~/search1.png" style="margin-right: 0px" Width="126px" />

<script>
function showBox() {
var theControl = document.getElementById("<%=Textbox1.ClientID %>");
theControl.style.display = "";
}

函数显示框(){
var theControl=document.getElementById(“”);
control.style.display=“”;
}


函数ValidNum(){
返回false;
}

谢谢

您的代码依赖于回发,因为您有一个用于显示文本框的服务器端事件处理程序。如果不在此处回发,则会阻止事件处理程序运行。如果您希望避免回发并仍然管理文本框的可见性,则必须在javascript中隐藏/显示文本框

control.style.display=“无”//隐藏

control.style.display=“block”//显示


感谢TGH提供的帮助我可以使用asp.net文本框吗?因为我的文本框中有很多函数它的文本框1\u TextChanged event删除以下行onClick=“return showBox();”将两个javascript函数放在一个包装函数中,并从onclientclickp调用它请解释问题。
  <asp:ImageButton ID="ImageButton1" runat="server" 
    OnClientClick="return ValidNum();" onClick="return showBox();" Height="52px" 
    ImageUrl="~/search1.png" style="margin-right: 0px" Width="126px" />

<script>
function showBox() {
var theControl = document.getElementById("<%=Textbox1.ClientID %>");
theControl.style.display = "";
}
<script>

        function ValidNum() {

            return false;

        }

 </script>