1、服务器控件button 怎么执行javascript 的函数2、服务器控件能不能设置当前页面的页眉页脚页边距,用下面这段javascript 无法实现
<script language="JavaScript">
var hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"
//设置网页打印的页眉页脚为空
function pagesetup_null(){
try{
var RegWsh = new ActiveXObject("WScript.Shell")
hkey_key="header"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")
hkey_key="footer"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")
}catch(e){}
}
pagesetup_null();
</script>
这段代码放html页面能执行成功,但是放在aspx里却无反应,这是为什么呢?3、服务器控件textbox 如何实现验证字符,不匹配的话有提示文字?谢谢各位大哥了
<script language="JavaScript">
var hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"
//设置网页打印的页眉页脚为空
function pagesetup_null(){
try{
var RegWsh = new ActiveXObject("WScript.Shell")
hkey_key="header"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")
hkey_key="footer"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")
}catch(e){}
}
pagesetup_null();
</script>
这段代码放html页面能执行成功,但是放在aspx里却无反应,这是为什么呢?3、服务器控件textbox 如何实现验证字符,不匹配的话有提示文字?谢谢各位大哥了
1.设置打印不显示的内容 <style type="text/css" media="print">
.noprint{display : none;}
</style>
<div class="noprint">
<table class="tableinfotb">
<tr>
<td align="center">
<input type="button"
class="formbutton" name="Submit"
value="<fmt:message key="public.button.back"/>"
onclick="javascript:history.go(-1)">
<input type="button"
class="formbutton" name="Submit"
value="打印"
onclick="printit();">
</td>
</tr>
</table>
</div>
2.打印网页 <script language="javascript">
var HKEY_RootPath="HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
// 设置页眉页脚为空
function PageSetup_del(){
alert("ddd");
try{
var WSc=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
WSc.RegWrite(HKEY_RootPath+HKEY_Key,"");
HKEY_Key="footer";
WSc.RegWrite(HKEY_RootPath+HKEY_Key,"");
}catch(e){}
}
//恢复页眉页脚
function PageSetup_set(){
try{
var WSc=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
WSc.RegWrite(HKEY_RootPath+HKEY_Key,"&w&b页码,&p/&P");
HKEY_Key="footer";
WSc.RegWrite(HKEY_RootPath+HKEY_Key,"&u&b&d");
}catch(e){} }
//打印
function printit()
{
document.getElementById("table1").style.height=800 + "px";
document.getElementById("table2").style.height=400 + "px";
fontZoom(16);
PageSetup_del();
window.print();
document.getElementById("table1").style.height="auto";
document.getElementById("table2").style.height="auto";
fontZoom(12);
}
//设置打印字体
function fontZoom(size)
{
var l = document.getElementsByTagName("td");
for( i=0;i<l.length;i++) {
l[i].style.fontSize=size+'px';
}
}
</script>
Page.RegisterClientScriptBlock("","<script>alert('xxx')</script>");
CS里面写:
1.服务器控件button's ID.Attributes["onclick"] = "javascript方法名";
例如:
^[A-Za-z]+$ //匹配由26个英文字母组成的字符串
^[A-Z]+$ //匹配由26个英文字母的大写组成的字符串
^[a-z]+$ //匹配由26个英文字母的小写组成的字符串
^[A-Za-z0-9]+$ //匹配由数字和26个英文字母组成的字符串
^\w+$ //匹配由数字、26个英文字母或者下划线组成的字符串你这个字符的定义范围是什么?
function Test(e)
{
alert(e.value);
}
</script>
<input type="text" onkeyup="Test(this)">
2.网页打印什么的google 百度 收索下 就有很多了
3. <script type="text/javascript">
function check(){
var username= document.all.username.value;
var re[a-zA-Z]{2}\d{4} ;
if(!(re.test(username))){
alert("用户名不正确\n");
return false;
}
return true;
}
</script>
username为文本框的name
<input type="text" name="username"></td>
出来的代码是这样的onclick="\<script type='text/javascript' language='javascript'/> window.open('PrintCost.aspx?fkdh='BX20100402450','newwindow', width='725',height='600')</script>;" 这个怎么解决呢?
OnClientClick调用JavaScript
OnClientClick="return js()" 返回true时,执行OnClick服务器端事件
第三个:用ajax吧!