如何在单击按钮上设置periority两个功能/方法? Asp.net C# [英] How can I set periority two function/method on one button click? Asp.net C#

查看:166
本文介绍了如何在单击按钮上设置periority两个功能/方法? Asp.net C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我的问题是如何在一键式按钮上设置tow功能/方法的优先级。我有一个java脚本函数调用,一个方法是代码隐藏。我想当我点击按钮然后第一个javascript函数调用,它取值,然后其他函数调用,这是代码隐藏,单击按钮(ASP.NET,C#)



< b>我尝试了什么:



这是我的代码aspx:

 < span class =code-keyword><   script     type   =  text / javascript >  
function myFunction(){
var person = prompt( 输入表名);

if (person!= null ){
document .getElementById( txtName)。innerHTML =人;

}
}
< / < span class =code-leadattribute> script >
表名< asp:TextBox ID = txtName runat = server 宽度 = 146px > < / asp:TextBox >
< asp:按钮 ID = Button2 ValidationGroup = s runat = server onclick = insert 文字 = < span class =code-keyword>创建表 / > //'插入'(代码隐藏方法)我想首先进行myfunction调用然后插入方法调用。



我该怎么做?

解决方案

你在寻找什么asp的OnClientClick 属性:按钮



你需要写如下:



< pre lang =ASP.NET> < asp:按钮 ID = Button2 ValidationGroup = s runat = 服务器 onclick = insert 文本 = 创建表 onClientClick = myFunction() / >


Hi..
My question is how can i set priority of tow function/method on one button click.I have one java script function call and one method is code behind.I want when i click on button then first javascript function call,its takes value and then other function call which is code behind,on single button click(ASP.NET ,C#)

What I have tried:

Here is my code aspx :

<script type="text/javascript">
    function myFunction() {
        var person = prompt("Enter Table Name");

        if (person != null) {
            document.getElementById("txtName").innerHTML = person;
       
        }
    }
</script>
Table Name<asp:TextBox ID="txtName" runat="server" Width="146px"></asp:TextBox>
 <asp:Button ID="Button2" ValidationGroup="s" runat="server" onclick="insert" Text="Create Table" /> //'insert '(code behind method) i want first myfunction call then "insert" method call.


How can i do this?

解决方案

What you are looking for in OnClientClick attribute of asp:Button

You need to write as below:

<asp:Button ID="Button2" ValidationGroup="s" runat="server" onclick="insert" Text="Create Table" onClientClick="myFunction()" />


这篇关于如何在单击按钮上设置periority两个功能/方法? Asp.net C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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