showModalDialog传参数问题
private void WriteScriptWithNoTree()
{
StringBuilder sb=new StringBuilder ( " ");
sb.Append ( " <script language=\ "javascript\ "> \n ");
sb.Append( "function ShowRefGridNoTree(sModuleID,sTableCode,nMultiSelect,sFilter,sWhere,sOrder)\n ");
sb.Append( "{\n ");
sb.Append( "var returnValue=window.showModalDialog(\ " "+HttpContext.Current.Request.ApplicationPath+ "/UserControls/RefFrameNoTree.aspx?ModuleID=\ "+sModuleID+\ "&TableCode=\ "+sTableCode+\ "&MultiSelect=\ "+nMultiSelect+\ "&Filter=\ "+sFilter+\ "&WhereSql=\ "+sWhere+\ "&OrderSql=\ "+sOrder,\ "\ " ");
// sb.Append( "var returnValue=window.showModalDialog(\ " "+HttpContext.Current.Request.ApplicationPath+ "/UserControls/RefFrameNoTree.aspx?module=111\ ",\ "\ " ");
sb.Append( ",\ "status:No;scroll:Yes;dialogWidth:750px;dialogHeight:550px;edge:raised;unadorned:Yes;resizable:Yes\ ");\n ");
sb.Append( "if(returnValue!=\ "undefined\ " && returnValue!=undefined) return returnValue;\n ");
sb.Append( "}\n ");
sb.Append( " </script> ");
if(!this.Page.IsClientScriptBlockRegistered ( "ShowRefEditorNoTreeScript "))
{
this.Page.RegisterClientScriptBlock ( "ShowRefEditorNoTreeScript ", sb.ToString ());
}
}
--------------------------------------------------
调用的时候:
imgShowSelector.Attributes.Add ( "onclick ", "ShowRefGridNoTree(\ " "+m_sModuleID + "\ ",\ " "+m_sTableCode+ "\ ",\ " "+ m_nMultiSelect + "\ ",\ " " + m_sFilter + "\ ",\ " " + m_sWhere + "\ ",\ " " + m_sOrder + "\ "); ");
发现m_sWhere 中有 "+"号的传过去会丢失
如:
"WHERE MaterialCatalog.CatalogID like ImportantMaterial.CatalogID + '% '"
传过去获取WhereSql的值就为"WHERE MaterialCatalog.CatalogID like ImportantMaterial.CatalogID '% '"
------解决方案--------------------Server.UrlEncode( "+ ")
------解决方案--------------------肯定要转码传递的,何止是一个+号会乱码,很多字符都会乱码
------解决方案--------------------\+
------解决方案--------------------顶 (【孟子E章】)
------解决方案--------------------http://www.cnblogs.com/halabazi/archive/2006/12/22/600168.html
------解决方案--------------------顶
------解决方案--------------------学习
------解决方案--------------------路过