StringBuilder script = new StringBuilder();
script.Append( " <script type= 'text/javascript '> \r ");
script.Append( "function form1.onsubmit()\r ");
script.Append( "{\r ");
script.Append( "var bool=false;\r ");
script.Append( "return bool;\r ");
script.Append( "}\r ");
script.Append( " </script> \r ");
Page.ClientScript.RegisterClientScriptBlock(typeof(Type), "onsubmit ", script.ToString());
最后生成为
<script type= 'text/javascript '>
function form1.onsubmit()
{
var bool=true;
return bool;
}
</script>
然后我想要在
var bool=true;
return bool;
之间来插入我对控件的验证如后台有
Page.ClientScript.RegisterClientScriptBlock(typeof(Type), "checkT1 ", " <script> function checkt1(bool){ ... } </script> ");
然后我要
function form1.onsubmit()
{
var bool=true;
return bool;
}
变成
function form1.onsubmit()
{
var bool=true;
checkt1(bool)
return bool;
}
要用什么方法最好
------解决方案--------------------------------------------------------
string script = @ "
function checkt1(bool)
{
...
}
function form1.onsubmit()
{
var bool=true;
checkt1(bool)
return bool;
}
";
Page.ClientScript.RegisterClientScriptBlock(typeof(Type), "checkT1 ", script);
------解决方案--------------------------------------------------------
字符串链接起来就好了阿,你前台怎么写后台就这么写啊
------解决方案--------------------------------------------------------
string script = @ "
function checkt1(bool)
{
...
}
function form1.onsubmit()
{
var bool=true;
checkt1(bool)
return bool;
}
";
Page.ClientScript.RegisterClientScriptBlock(typeof(Type), "checkT1 ", script);
--------------
字符串链接起来就好了阿,你前台怎么写后台就这么写啊
--------
意思都一样,就是把前台的javascript在后台用字符串写出来,所以前台该怎么写,就把后台的字符串写成什么样就行了
------解决方案--------------------------------------------------------
占上
------解决方案--------------------------------------------------------
呵呵 正如楼上所说
------解决方案--------------------------------------------------------
楼主是不是要改写asp.net自动生成的js???如果是,直接在页面后面重写一个,当有两个完全相同的function时.js会执行最后一个.
------解决方案--------------------------------------------------------
基本没有看懂。up