2014-10-11 1 views
0

Jquery Dialog을 사용하고 있으며 메시지 길이가 너무 깁니다. 나는

자바 스크립트

function ShowPopup(message) { 
    $(function() { 
     $("#dialog").html(message); 
      $("#dialog").dialog({ 
      title: "New words result", 
      resizable: true, 
      height: "auto", 
      width:"900px", 
      buttons: { 
       }, 
      modal: true 
     }); 
    }); 
}; 

는 C#

string sqlconn = ConfigurationManager.AppSettings["vConnString"].ToString(); 
DataTable dt = new DataTable(); 
SqlConnection con = new SqlConnection(sqlconn); 
string QUERY = "Sproc_FindNewWords"; 
SqlCommand cmd = new SqlCommand(QUERY, con); 
cmd.CommandType = CommandType.StoredProcedure; 
cmd.Parameters.AddWithValue("@AM_AssetID", ddlGroup.SelectedItem.Text); 
SqlDataAdapter da = new SqlDataAdapter(cmd); 
da.Fill(dt); 
StringBuilder sb = new StringBuilder(); 

if (dt.Rows.Count > 0) 
{ 
    for (int i = 0; i < dt.Rows.Count; i++) 
    { 
     if (dt.Rows[i]["val"].ToString()!="") 
     { 
      sb.Append("<span>" + dt.Rows[i]["val"].ToString() + "</span>,&nbsp;"); 
     }    
    }   
} 

string message = sb.ToString();   
ScriptManager.RegisterStartupScript(this,GetType(), "Popup", "ShowPopup('" + message + "');", true); 

메시지 텍스트가 작을 때 내가 $("#dialog").html(message); 의 정확한 길이 무엇인지에 대해 알고 싶은 그것의 다음 코드를 사용하고 잘 작동하고 텍스트가 너무 크면 같은 방식으로 작동하지 않습니다.

또는

다른 방법을 제안 해주십시오 Jquery Dialog에 결과를 표시합니다.

+0

'console.log (message.length);'를 사용하여 메시지 길이를 확인할 수 있습니다. 길이 메시지는 Webservices로 작업 할 때 나타날 수 있습니다. 사용중인 웹 서비스입니까? –

+0

아니요 'Button_Click' 이벤트에서 함수를 호출하고 있습니다 – Gitz

+0

시도해 보셨습니까? - http://roam.be/notebook/2012/jquery-dialog-keep-your-hands-of-my-content.html Jquery 대화 상자에서 텍스트를 선택하거나'900px' 대신에'auto'를 사용하십시오. –

답변

0

Take Div. aspx; aspx.cs JQuery와의

divmessage.innerHTML=message; 
ScriptManager.RegisterStartupScript(this,GetType(), "Popup", "ShowPopup();", true); 

<div id="divmessage" style='display:none' runat='server'/> 

function ShowPopup() { 
var message=$("#divmessage").html(); 
if(message.length>0) 
$(function() { 
    $("#dialog").html(message); 
     $("#dialog").dialog({ 
     title: "New words result", 
     resizable: true, 
     height: "auto", 
     width:"900px", 
     buttons: { 
      }, 
     modal: true 
    }); 
}); 

};

관련 문제