2007.9.17

<asp:Button ID="Button1"  Text="取消" CssClass="btn" OnClientClick="javascript:window.location.reload();" runat="server" /><!--window.location.reload();window.close();-->

  Response.Write("<script>alert('已成功修改密码,请记住新密码!\\n用户名:" + txt_user_login.Text.Trim().Replace("'""''"+ "\\n  密码:" + txt_confirm_new_pass.Text.Trim() + "');window.location.href='login.aspx';</script>");
//如果是最后一句,则其后不用return ||||| Response.Redirect()是在server端执行的动作,而Alert()是client端的动作,所以即使alert()在responser.redirect()之前也是没有用的
        
//Response.Redirect("login.aspx");  
//Response.Redirect("index.aspx") 之后,Http 服务器回答客户端 302 Object Moved(可能吧),然后客户端直接访问新的网址了,显然根本就没有收到 redirect 之前的内容,用 ieHttpHeaders 看一下

comm_update.StatementCompleted += new StatementCompletedEventHandler(comm_update_StatementCompleted);
//在下面这句comm_update.ExecuteNonQuery(); 之后执行该“事件”!
                comm_update.ExecuteNonQuery();  


 
void comm_update_StatementCompleted(object sender, StatementCompletedEventArgs e)
    
{
        
//throw new Exception("The method or operation is not implemented.");
        Response.Write("<script>alert('已成功修改密码,请记住新密码!\\n用户名:"+str_user_login+"\\n  密码:"+txt_confirm_new_pass.Text.Trim()+"');</script>");
        
return;
    }


    <script type="text/javascript" language="javascript">
    
function getCurrentPage() 
    
{
       thisURL 
= document.URL;
       alert(thisURL);
//完整路径:http://localhost:7933/wltbs/pd_user_changepass.aspx
       
       thisPage 
= thisURL.substring( thisURL.lastIndexOf("/") );//从最后一个/(包括)取到最后
       alert(thisPage);
       
return thisPage;
    }


   
function popPage(page,url)
    
{
      thisPage 
= getCurrentPage();
      
if (thisPage == "/"
      
{
        thisPage 
= "/index.asp";
      }

      
if ( thisPage == page )
      
{
         window.open(url);
      }

    }


function l(boardid) 
{
    
return (getCurrentPage()=="/list.asp?boardid="+boardid)?true:false;
}

if( l(1)||l(3)||l(6)||l(7) )
{
   popPage( getCurrentPage(), 
"URL" ) ;
}

    
</script>

<body style="margin-top:0px; margin-left:0px; margin-right:0px;" class="body_bj" onload="return getCurrentPage();">

function show_cal()//left
     {
        
if(document.all("pnl_cal").style.visibility == "visible")//== 不是 =
        {   
            document.all(
"pnl_cal").style.visibility="hidden";
        }

        
else
        
{            
            document.all(
"pnl_cal").style.visibility="visible"//在后台visible=false了,前台就再也不可能显示它了
        }

      
     }

 //    //ddlBankName.SelectedItem.Text = "";//body 的①onload 事件函数 和 ②ddlPayMode's onchange()已经将ddlBankName  -->disabled 所以这里的赋值是不能成功的.

//Type t = sdr["flag_nuse"].GetType();
            b = (Boolean)sdr["flag_nuse"];

 SqlCommand comm = new SqlCommand();//sdr对应字段有两个值,必定一个为null
                comm.Connection = conn;
                
//SqlParameter sp_fee = new SqlParameter("@id", SqlDbType.NVarChar, 50);//只是new一个新的SqlParameter并没有把它加到当前的comm上
                
//sp_fee.Value = arr_fee_id_load[i];
                comm.Parameters.Clear();//清除以前的Parameters集合
                comm.Parameters.Add("@id", SqlDbType.NVarChar, 50);//添加到当前的SqlParameters集合上
                comm.Parameters["@id"].Value = arr_fee_id_load[i];//给正在使用的SqlParameter赋值
                comm.CommandText = "select_from_fee";
                comm.CommandType 
= CommandType.StoredProcedure;

在pd_user_changepass.aspx页面内: 

 Page.LoadComplete 
+= new EventHandler(Page_LoadComplete);

 
void Page_LoadComplete(object sender, EventArgs e)
    
{
        
//throw new Exception("The method or operation is not implemented.");
        Response.Redirect("pd_user_changepass.aspx");//死循环
    }

 /// <summary>
    
/// 保存修改后的User_Login的值 属性
    
/// </summary>

    public string str_user_login
    
{
        
get 
        
{
            
if (ViewState["str_user_login"== null)
                
return "";
            
else
                
return ViewState["str_user_login"].ToString();
        }

        
set 
        
{
            ViewState[
"str_user_login"= value.ToString();
        }

    }






/*******************************************************************************************/

 
if (str_user_login == "")//str_user_login属性一直保持“用户名”不存在的那“次”输入的值
        {
            str_user_login 
= txt_user_login.Text.Trim().Replace("'""''");//保存修改后的TextBox:txt_user_login的值
        }
原文地址:https://www.cnblogs.com/simhare/p/896227.html