2011-02-02 2 views
0

난 그냥 내가 다음 <asp:UpdatePanel ...을 제거하면 내가 경고 메시지가 나타났습니다에는 경고 메시지가없는 이상을 코드 숨김에서 메시지를 경고하는 방법나는`<ASP가있는 경우 : UpdatePanel ...`poup

protected void gv_RowCommand(object sender, GridViewCommandEventArgs e) 
{ 
    if (e.CommandName == CRUID.Delete.ToString()) 
    { 

    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", "alert('Deleted successfully!');", true); 

or 

// Define the name and type of the client scripts on the page. 
     String csname1 = "PopupScript"; 
     Type cstype = this.GetType(); 

     // Get a ClientScriptManager reference from the Page class. 
     ClientScriptManager cs = Page.ClientScript; 

     // Check to see if the startup script is already registered. 
     if (!cs.IsStartupScriptRegistered(cstype, csname1)) 
     { 
      StringBuilder cstext1 = new StringBuilder(); 
      cstext1.Append("<script type=text/javascript> alert('Hello World!') </"); 
      cstext1.Append("script>"); 

      cs.RegisterStartupScript(cstype, csname1, cstext1.ToString()); 
     } 
    } 
} 

protected override void Page_Load(object sender, EventArgs e) 
{ 
    gv.DataSourceID = "gvDataSource"; 
} 

추신 : 나는 방법의 수를 시도했지만 나는 결코 경고 메시지를 얻을 아래 내 코드 내 GridView 컨트롤을 바인딩 ObjectDataSource를을 사용하여 스피

+0

디버깅 할 때 gv_RowCommand에 중단 점을 넣으면 어떻게됩니까? – JumpingJezza

+0

네, 거기 도착하지만 팝업 경고하지 않습니다 –

답변

0

시도 변화 :

ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Deleted successfully!');", true); 
관련 문제