|
|
|
|
using System;
|
|
|
|
|
using System.Web.UI;
|
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace HuizhongLibrary.Control
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
[DefaultProperty("Value"),
|
|
|
|
|
ToolboxData("<{0}:DataGridRadioButton runat=server></{0}:DataGridRadioButton>"),ParseChildren(true),
|
|
|
|
|
PersistChildren(false)]
|
|
|
|
|
public class DataGridRadioButton : RadioButton,INamingContainer,IPostBackDataHandler
|
|
|
|
|
{
|
|
|
|
|
public DataGridRadioButton() : base()
|
|
|
|
|
{
|
|
|
|
|
this.PreRender +=new EventHandler(DataGridRadioButton_PreRender);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DataGridRadioButton_PreRender(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Page.RegisterHiddenField("RadioButton_Checked", this.Checked.ToString());
|
|
|
|
|
// Page.RegisterStartupScript("jsSetRadioButton_Checked", "<script type=\"text/javascript\">document.getElementById("+this.ClientID+").Checked=" + this.Checked.ToString() + ";</script>");
|
|
|
|
|
// this.Attributes.Add("onclick","document.getElementById('RadioButton_Checked').value = this.Checked;");
|
|
|
|
|
// <20><><EFBFBD>ؼ<EFBFBD>ע<EFBFBD><D7A2>ΪҪ<CEAA><D2AA><EFBFBD><EFBFBD>ҳ<EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>лط<D0BB><D8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀؼ<C4BF>
|
|
|
|
|
if (Page != null) Page.RegisterRequiresPostBack(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
|
|
|
|
|
|
private string Value
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
string val = Attributes["value"];
|
|
|
|
|
if(val == null)
|
|
|
|
|
val = UniqueID;
|
|
|
|
|
else
|
|
|
|
|
val = UniqueID + "_" + val;
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Rendering
|
|
|
|
|
|
|
|
|
|
protected override void Render(HtmlTextWriter output)
|
|
|
|
|
{
|
|
|
|
|
RenderInputTag(output);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RenderInputTag(HtmlTextWriter htw)
|
|
|
|
|
{
|
|
|
|
|
htw.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
|
|
|
|
|
htw.AddAttribute(HtmlTextWriterAttribute.Type, "radio");
|
|
|
|
|
htw.AddAttribute(HtmlTextWriterAttribute.Name, GroupName);
|
|
|
|
|
htw.AddAttribute(HtmlTextWriterAttribute.Value, Value);
|
|
|
|
|
if(Checked)
|
|
|
|
|
htw.AddAttribute(HtmlTextWriterAttribute.Checked, "checked");
|
|
|
|
|
if(!Enabled)
|
|
|
|
|
htw.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
|
|
|
|
|
|
|
|
|
|
string onClick = Attributes["onclick"];
|
|
|
|
|
if(AutoPostBack)
|
|
|
|
|
{
|
|
|
|
|
if(onClick != null)
|
|
|
|
|
onClick = String.Empty;
|
|
|
|
|
onClick += Page.GetPostBackClientEvent(this, String.Empty);
|
|
|
|
|
htw.AddAttribute(HtmlTextWriterAttribute.Onclick, onClick);
|
|
|
|
|
htw.AddAttribute("language", "javascript");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(onClick != null)
|
|
|
|
|
htw.AddAttribute(HtmlTextWriterAttribute.Onclick, onClick);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(AccessKey.Length > 0)
|
|
|
|
|
htw.AddAttribute(HtmlTextWriterAttribute.Accesskey, AccessKey);
|
|
|
|
|
if(TabIndex != 0)
|
|
|
|
|
htw.AddAttribute(HtmlTextWriterAttribute.Tabindex,
|
|
|
|
|
TabIndex.ToString(NumberFormatInfo.InvariantInfo));
|
|
|
|
|
htw.RenderBeginTag(HtmlTextWriterTag.Input);
|
|
|
|
|
htw.RenderEndTag();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region IPostBackDataHandler Members
|
|
|
|
|
|
|
|
|
|
void IPostBackDataHandler.RaisePostDataChangedEvent()
|
|
|
|
|
{
|
|
|
|
|
OnCheckedChanged(EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IPostBackDataHandler.LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
string value = postCollection[GroupName];
|
|
|
|
|
if((value != null) && (value == Value))
|
|
|
|
|
{
|
|
|
|
|
if(!Checked)
|
|
|
|
|
{
|
|
|
|
|
Checked = true;
|
|
|
|
|
result = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(Checked)
|
|
|
|
|
Checked = false;
|
|
|
|
|
}
|
|
|
|
|
// if (postCollection["RadioButton_Checked"]!=null)this.Checked=Convert.ToBoolean(postCollection["RadioButton_Checked"]);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|