日期:2014-05-18  浏览次数:21005 次

javascript语言弹出提示输入不能为空
我用的vs2005里的textbox控件,怎么样才能办到呢??我在网上搜的全是input(text)的控件啊,input控件又不知道该怎么把数据从里面提取出来,大家帮帮忙啊,尽量沾出代码啊,

------解决方案--------------------
其实微软很多时候是把js脚本封装成服务器脚本,我们也可以如法炮制:
C# code
public static class JSHelper {
    public static void Alert(string pValue) {
        pValue = MyHelper.ToString(pValue);
        string _s = "alert('" + pValue + "');";
        JSHelper.Execute(_s);
        }

    public static void Execute(string pKey, string pjsString) {
        string _jsString = MyHelper.ToString(pjsString);
        string _Key = MyHelper.ToString(pKey);
        Page _thisPage = (Page)HttpContext.Current.Handler;
        ScriptManager.RegisterStartupScript(_thisPage, _thisPage.GetType(), _Key, _jsString, true);
        }
    public static void Execute(string pjsString) {
        JSHelper.Execute(MyHelper.ToString(Guid.NewGuid()), pjsString);
        }

    public static void SetFocus(string pClientId) {
        pClientId = MyHelper.ToString(pClientId);
        MyHelper.Assert(pClientId != "", new ArgumentException("参数pClientId不允许为空"));
        string _s = "var _focus = document.getElementById('" + pClientId + "');";
        _s += "if(_focus)_focus.focus();";
        JSHelper.Execute(Guid.NewGuid().ToString(), _s);
        }