Try this:
aspx file:
<form id="form1" runat="server">
This is some content being displayed
<br />
<a id="blueLink" href="http://forums.asp.net/AddPost.aspx?ReplyToPostID=2597480&Quote=False#" runat="server" onclick="__doPostBack('ColorLinkPostBack', 'Blue');">Set to Blue</a>
<a id="redLink" href="http://forums.asp.net/AddPost.aspx?ReplyToPostID=2597480&Quote=False#" runat="server" onclick="__doPostBack('ColorLinkPostBack', 'Red');">Set to Red</a>
</form>
aspx.cs file:
protected void Page_Load(object sender, EventArgs e)
{
this.ClientScript.GetPostBackEventReference(this, string.Empty);
if (this.IsPostBack)
{
string eventTarget = (this.Request["__EVENTTARGET"] == null) ? string.Empty : this.Request["__EVENTTARGET"];
string eventArgument = (this.Request["__EVENTARGUMENT"] == null) ? string.Empty : this.Request["__EVENTARGUMENT"];
if ( eventTarget == "ColorLinkPostBack" )
{
System.Text.StringBuilder styleScript = new System.Text.StringBuilder();
styleScript.Append("<style type=\"text/css\">\n");
styleScript.Append("BODY\n");
styleScript.Append("{\n");
styleScript.AppendFormat(" color:{0};\n", eventArgument);
styleScript.Append("}\n");
styleScript.Append("</style>\n");
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "BodyStyleSheet", styleScript.ToString());
}
}
else
{
string defaultColor = "Green";
System.Text.StringBuilder styleScript = new System.Text.StringBuilder();
styleScript.Append("<style type=\"text/css\">\n");
styleScript.Append("BODY\n");
styleScript.Append("{\n");
styleScript.AppendFormat(" color:{0};\n", defaultColor);
styleScript.Append("}\n");
styleScript.Append("</style>\n");
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "BodyStyleSheet", styleScript.ToString());
}
}
NC...