问题-:
客户端的js代码
<script language='javascript'>
<!--
function checkdata() {
if (Jtrim(document.forms['Form1'].elements['TextBox1'].value)=='') {
window.alert ("请输入您的姓名 !")
return false
}
if (Jtrim(document.forms['Form1'].elements['TextBox2'].value)=='') {
window.alert ("密码不得为空!")
return false
}
return true
}
-->
</script>
<form id="Form1" ruant="server">
<asp:Button id="button1" runat="server"/>服务器端
void Page_Load(object sender,EventArgs e)
{
button1.Attributes .Add("onclick","checkdata()");
}void button1_OnClick(object sender,EventArgs e)
{
user=TextBox1.Text.Trim();
pwd=TextBox2.Text.Trim();
SqlConnection myconn =(SqlConection)HttpContext.Current.Items(Connection);
myconn.Open();
strsql="select * from tablea where user='"+user+"' and pwd='"+pwd+"'";
SqlCommand cmd = new SqlCommand(strsql,myconn);
SqlDataReader dr = cmd.ExecuteReader();
if(dr.Read())
{
Response.Write("<script>window.open(..............);</script>");
}
}
但在状态栏上会显示页面上有错!!!!! 难道一个按钮只能在客户端用或服务端用么。问题2:
如果不是上面的方法写我这么写。
bool boola=Convert.ToBoolean(TextBox1.Text=="");
bool boolb=Convert.ToBoolean(TextBox2.Text=="");if(boola==true && boolb==false)
{
Response.Write("<script>alert('用户ID不能为空!');</script>");
}
if(boola==false && boolb==true)
{
Response.Write("<script>alert('用户密码不能为空!');</script>");
}
if(boola==true && boolb==true)
{
Response.Write("<script>alert('用户ID、用户密码不能为空!');</script>");
}
碰到的问题是我点击按扭后会出现个警告框。但是我不按确定后面显示是空白页面。按后又回到原来有内容的也面。如何让它输入不正确后在原有的页面上跳出警告框。问题三:
DataNavigateUrlFormatString="javascript:window.open('cus_jz.aspx?PubOpCorpCode={0}','_blank','width=500,height=250');"
弹出子窗口但父窗口却显示为[object]的空白页面。
梅花雨修改后的代码
DataNavigateUrlFormatString="javascript:window.open('cus_jz.aspx?PubOpCorpCode={0}','_blank','width=500,height=250');void(0);"
但是父窗口的内容有,调试程序时发现父窗口DataGrid的内容却没有了.不知道为什么。
客户端的js代码
<script language='javascript'>
<!--
function checkdata() {
if (Jtrim(document.forms['Form1'].elements['TextBox1'].value)=='') {
window.alert ("请输入您的姓名 !")
return false
}
if (Jtrim(document.forms['Form1'].elements['TextBox2'].value)=='') {
window.alert ("密码不得为空!")
return false
}
return true
}
-->
</script>
<form id="Form1" ruant="server">
<asp:Button id="button1" runat="server"/>服务器端
void Page_Load(object sender,EventArgs e)
{
button1.Attributes .Add("onclick","checkdata()");
}void button1_OnClick(object sender,EventArgs e)
{
user=TextBox1.Text.Trim();
pwd=TextBox2.Text.Trim();
SqlConnection myconn =(SqlConection)HttpContext.Current.Items(Connection);
myconn.Open();
strsql="select * from tablea where user='"+user+"' and pwd='"+pwd+"'";
SqlCommand cmd = new SqlCommand(strsql,myconn);
SqlDataReader dr = cmd.ExecuteReader();
if(dr.Read())
{
Response.Write("<script>window.open(..............);</script>");
}
}
但在状态栏上会显示页面上有错!!!!! 难道一个按钮只能在客户端用或服务端用么。问题2:
如果不是上面的方法写我这么写。
bool boola=Convert.ToBoolean(TextBox1.Text=="");
bool boolb=Convert.ToBoolean(TextBox2.Text=="");if(boola==true && boolb==false)
{
Response.Write("<script>alert('用户ID不能为空!');</script>");
}
if(boola==false && boolb==true)
{
Response.Write("<script>alert('用户密码不能为空!');</script>");
}
if(boola==true && boolb==true)
{
Response.Write("<script>alert('用户ID、用户密码不能为空!');</script>");
}
碰到的问题是我点击按扭后会出现个警告框。但是我不按确定后面显示是空白页面。按后又回到原来有内容的也面。如何让它输入不正确后在原有的页面上跳出警告框。问题三:
DataNavigateUrlFormatString="javascript:window.open('cus_jz.aspx?PubOpCorpCode={0}','_blank','width=500,height=250');"
弹出子窗口但父窗口却显示为[object]的空白页面。
梅花雨修改后的代码
DataNavigateUrlFormatString="javascript:window.open('cus_jz.aspx?PubOpCorpCode={0}','_blank','width=500,height=250');void(0);"
但是父窗口的内容有,调试程序时发现父窗口DataGrid的内容却没有了.不知道为什么。
解决方案 »
- <spacer>标记在label.text输出中不起作用!
- 关于ASP。NET中欠入FrameSet后整个页面的大小问题
- 框架嵌套问题
- asp.net2.0的publish问题(急)
- 支持asp.net 的html编辑器
- 我的javasript语句怎么在asp.net中部管用阿,郁闷
- 简单问题,来接分吧~~~~~~~~~
- 关于Wizard控件
- 自定义控件中的图片问题
- 请问有没有直接可以HTML(XHTML、SHTML)生成XML-XSL!!的工具
- 100分:初学ASP网站建成,求网站评测,美工和功能方面!评测送分!!!!一定结贴
- 请问asp.net2.0正式版最早什么时候公布? 我想学学2.0,不过还没买相应的有关书籍,想等2.0正式推出以后再买,各位认为怎么样?
这个应是很简单的
function checkdata() {
if (document.all.TextBox1.value=='' || document.all.TextBox1.value.length==0) {
window.alert ("请输入您的姓名 !")
return false
}
if (document.all.TextBox2.value=='' || document.all.TextBox2.value.length==0) { window.alert ("密码不得为空!")
return false
}
return true
}2,不要在服务器端写
3,请说全一点.不太看懂
客户端的js代码
<script language='javascript'>
<!--
function checkdata() {
if (document.all['TextBox1'].value)=='') {
window.alert ("请输入您的姓名 !")
return false
}
if (document.all['TextBox2'].value)=='') {
window.alert ("密码不得为空!")
return false
}
return true
}
-->
</script>
<form id="Form1" ruant="server">
<asp:Button id="button1" runat="server"/>服务器端
void Page_Load(object sender,EventArgs e)
{
button1.Attributes .Add("onclick","return checkdata()");//这里也改一下
}void button1_OnClick(object sender,EventArgs e)
{
user=TextBox1.Text.Trim();
pwd=TextBox2.Text.Trim();
SqlConnection myconn =(SqlConection)HttpContext.Current.Items(Connection);
myconn.Open();
strsql="select * from tablea where user='"+user+"' and pwd='"+pwd+"'";
SqlCommand cmd = new SqlCommand(strsql,myconn);
SqlDataReader dr = cmd.ExecuteReader();
if(dr.Read())
{
Response.Write("<script>window.open(..............);</script>");
}
}
在父窗口打开了一个main.aspx子窗口货物列表goods.aspx
在goods.aspx里用datagrid里的连接
DataNavigateUrlFormatString="javascript:window.open('cus_jz.aspx?PubOpCorpCode={0}','_blank','width=500,height=250');" 打开一个goods.aspx的子窗口cus_jz.aspx
但是在goods.aspx里却显示[object]然后就是空白。
用梅花雨的代码解决了这个问题,但是原来goods.aspx上面的datagrid有记录显示的现在都没有了不知道为什么。
string scipt="<script>alert('用户ID不能为空!');</script>";
if this.IsClientScriptBlockRegistered("kkk")
{
this.RegisterClientScriptBlock("kkk",scipt);
}3,你的可以在dataBind中这样
on_itemDataBound()
{
e.item.cells[0].text="a href="#" onclick="javascript:window.open('cus_jz.aspx?PubOpCorpCode="+e.item.datakeys[e.itemindex]+"',,'width=500,height=250')>"+e.item.cells[0].text+"</a>";
}
Response.End();式式