在asp.net中从javascript函数访问C#变量,反之亦然

时间:2013-07-23 19:34:50

标签: c# javascript asp.net

我有一个函数可以检查文本框中是否只有数字。如果没有通过,程序将不会执行sql插件。但是,我需要显示弹出消息。 popUp函数在javascript代码中,变量alertString在服务器端代码中。如何在按钮点击代码中调用popUp函数?该页面进行回发,所以我真的不知道该怎么做。如果有什么需要更清楚,我可以发布更多的代码。我正在使用视觉工作室2005.页面似乎只是刷新。如果我从onclientclick返回false,它可以工作,但我的executeinsert方法将不起作用

按键功能

protected void Button3_Click(object sender, EventArgs e)
    {

        if (CheckStrings()) //checkstrings funciton
        {
            Button3.Attributes.Add("onclick", "return false;");//fails
            string script = "delayer(5000);";
            ClientScript.RegisterStartupScript(typeof(Page), "ButtonAlert", script, true); 
//doesn't work if onclientlick returns true.

        }
        else
        {
...


            ExecuteInsert(dtTime, intShift, intOperator, Line1, canCode1, intCanVac1, intCanTemp1, intImage1, intSeam1, strComments1, null, null, null,
                false, null, null, false, intSKU, Line2, canCode2, intCanVac2, intCanTemp2, intSeam2, strComments2, null, intSKU2, intCoredia1, intCoredia2); 
//fails if I return false for client click
        }
    }

0 个答案:

没有答案
相关问题