想要在点击按钮的同时查看条件 [英] want to check a condition while click on button

查看:60
本文介绍了想要在点击按钮的同时查看条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在点击按钮的同时查看条件。

我在按钮上调用脚本来获取消息框。

喜欢这个

-----------

.aspx页面

Hi,
I want to check a condition while click on button.
i call a script to the button for getting a message box.
like this
-----------
.aspx page

<script type = "text/javascript">
        function Confirm() {
            var confirm_value = document.createElement("INPUT");
            confirm_value.type = "hidden";
            confirm_value.name = "confirm_value";
            if (confirm("Do you want to save data?")) {
                confirm_value.value = "Yes";
            } else {
                confirm_value.value = "No";
            }
            document.forms[0].appendChild(confirm_value);
        }
    </script>




<asp:CheckBox ID="chkbox" runat="server" />
   <asp:Button ID="btnConfirm" runat="server" OnClick = "OnConfirm" Text = "Raise Confirm" OnClientClick = "Confirm()"/>





.cs文件



.cs File

public void OnConfirm(object sender, EventArgs e)
    {
        string confirmValue = Request.Form["confirm_value"];
        if (confirmValue == "Yes")
        {
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked YES!')", true);
        }
        else
        {
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked NO!')", true);
        }
    }

现在我想检查支票箱是否选择或不是按钮点击

NOW I WANT TO CHECK THE CHECK BOX IS SELECT OR NOT DURING THE BUTTON CLICK

推荐答案

嗨Manju,

您可以在javascript函数中获取复选框控件的值



Hi Manju,
You can get the value of the checkbox control in your javascript function

function Confirm() {
// your code here
 var chk = document.getElementById("chkbox").checked;
 alert(chk );
}





希望这会对你有所帮助。



问候,

Lok ..



Hope this helps you.

Regards,
Lok..


使用javascript的确认功能 [ ]



无需签入
use Confirm function of javascript []

And no need to check in the
public void OnConfirm(object sender, EventArgs e)



再次为用户点击是或否。

public void OnConfirm(object sender,EventArgs e)
仅当用户单击Yes时才会调用


again for the Yes or NO clicked by user.
public void OnConfirm(object sender, EventArgs e)
will be called only if the user click Yes.


这篇关于想要在点击按钮的同时查看条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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