日期:2014-05-19  浏览次数:20572 次

为什么不能运行呀?
using   System;
using   System.Collections;
using   System.ComponentModel;
using   System.Data;
using   System.Drawing;
using   System.Web;
using   System.Web.SessionState;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.HtmlControls;

namespace   onprerender
{
///   <summary>
///   WebForm1   の概要の説明です。
///   </summary>

[DefaultProperty( "Text "),ToolboxData( " <{0}:WebForm1   runat   =   server> </{0}:WebForm1> ")]
public   class   WebForm1   :   System.Web.UI.Page        
{
[Bindable(true),Category( "Appearance ")]
public   string   Message
{
get  
{
object   popupMessage   =   this.ViewState[ "Message "];
if(Message   !=   null)
return   this.ViewState[ "Message "].ToString();
else
return   "welcome! ";
}
set
{
ViewState[ "Message "]   =   value;
}
}

[Bindable(true),Category( "Appearance ")]

public   bool   Enabled
{
get
{
object   enabled   =   this.ViewState[ "Enabled "];
if   (enabled   !=null)
return   (bool)   this.ViewState[ "Enabled "];
else
return   true;
}
set
{
ViewState[ "Enabled "]   =   value;
}
}

protected   override   void   OnPreRender(EventArgs   e)
{
base.OnPreRender(e);
string   scriptKey   = "intoPopupMessage: "   +   this.UniqueID   ;
if   (!Page.IsStartupScriptRegistered(scriptKey)   &&   this.Enabled   &&   !Page.IsPostBack   )
{
string   scriptBlock   =   @ " <script   language   =   " "Javascript " ">
<!--
alert( " "%%POPUP_MESSAGE%% " ");
//-->
</script> ";
scriptBlock   =   scriptBlock.Replace( "%%POPUP_MESSAGE%% ",this.Message);
Page.RegisterStartupScript(scriptKey,scriptBlock);
}

}
}

}


------解决方案--------------------
又是对日软件……兄台大连的?
------解决方案--------------------
string scriptBlock = @ " <script language = 'Javascript '> <!--alert( '%%POPUP_MESSAGE%% ');//--> </script> ";

把字符串里的双引号换成单引号,或者把前面的@去掉,用\ "代表双引号。