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

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
现在有我一个页面a.aspx

上面有两个服务器输入文本框     txtName,txtEmail   一个服务器按钮   btnLogin

现在想我在两个文件框中输入     aa,     aa@sina.com     点按钮,做两个操作
一个是调一个判断方法,即入数库操查找是否存在此用户,如保存在此用户则弹出b.aspx页,

现在我给出我的代码

string     userId     =   Define.GetUserID(this.txtName.Text,this.txtEmail.Text);     //判断是否存在此输入的用户
if(userId   !=   " ")
{

// this.btnLogin.Attributes.Add( "onclick ", " <script   language= 'javascript '> window.open( '../User/default.aspx ', 'newwindow '); </script> ");


// Page.RegisterClientScriptBlock( "onclick ", " <script   language= 'javascript '> window.open( '../User/default.aspx ', 'newwindow '); </script> ");
}
else
{
Page.RegisterStartupScript( " ", " <script> alert( '输入用户不存在或邮件! ') </script> ");
}


上面的代码,就是不能弹出窗体,服务端如何写
   


------解决方案--------------------
给你一个我常用的弹出窗口函数后台使用的
/// <summary>
/// 在某个页面弹出指定大小的窗口
/// </summary>
/// <param name= "mypage "> </param>
/// <param name= "PagePath "> </param>
/// <param name= "windowName "> </param>
/// <param name= "Top "> </param>
/// <param name= "Left "> </param>
/// <param name= "width "> </param>
/// <param name= "height "> </param>
public static void OpenPopUp(System.Web.UI.Page mypage, string PagePath, string windowName, int Top, int Left, int width, int height)
{
string clientScript;
string windowAttribs;
windowAttribs = "left= " + Left.ToString() + "px, " +
"top= " + Top.ToString() + "px, " +
"width= " + width.ToString() + "px, " +
"height= " + height.ToString() + "px, " +
"left= '+((screen.width - " + width.ToString() + ") / 2)+ ', ";
clientScript = " <script language= 'javascript '> window.open( ' " + PagePath + " ', ' " +
windowName + " ', ' " + windowAttribs + " '); </script> ";
if (!mypage.ClientScript.IsStartupScriptRegistered( "PopupWin "))
mypage.ClientScript.RegisterStartupScript(mypage.GetType(), "PopupWin ", clientScript);
}

你的代码可改为:
if(userId != " ")
{

OpenPopUp(this,.......);
}
else
{
Page.RegisterStartupScript( " ", " <script> alert( '输入用户不存在或邮件! ') </script> ");
}