S
Sam Samnah
I am building a custome control and I need to access the information in the
hidden field (HtmlInputHidden HIH) so that when a button is pressed the
information in the hidden fields value is returned. Somehow, when the
submit button is pressed the value in the Hidden field disappears into cyber
nothing. Please help. This application is supremely important to me.
Anyhow is greatly appreciated thank you
the code is as follows:
public class FreeForm : WebControl, IPostBackDataHandler
{
HtmlGenericControl HGC;
HtmlInputHidden HIH;
public FreeForm(): base(HtmlTextWriterTag.Table)
{}
public string Text
{
get{return HIH.Value;}
set{HIH.Value=value;}
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender (e);
if(!Page.IsClientScriptBlockRegistered("startUp"))
{
StringBuilder jsload=new StringBuilder();
jsload.Append(@"Some javascript not needed here"); // information is
transfered from the div tag to the hidden tag
// using client side code.
string CMSUpReg=jsload.ToString();
Page.RegisterClientScriptBlock("startUp",CMSUpReg);
}
}
protected override void CreateChildControls()
{
Controls.Add(new LiteralControl("<tr bgcolor='#ffffff' height='100%'
width='100%'>"));
Controls.Add(new LiteralControl("<td valign='top'>"));
HIH=new HtmlInputHidden();
HIH.Attributes.Add("value",Text);
HIH.Attributes.Add("name",this.UniqueID);
Controls.Add(HIH);
HGC=new HtmlGenericControl("div");
HGC.Attributes.Add("CONTENTEDITABLE","true");
HGC.Attributes.Add("width","100%");
HGC.Attributes.Add("height","100%");
HGC.Attributes.Add("onBlur","moveCurser(" + HIH.UniqueID + ");");
HGC.Attributes.Add("id","oDiv");
Controls.Add(HGC);
Controls.Add(new LiteralControl("</td>"));
Controls.Add(new LiteralControl("</tr>"));
base.CreateChildControls ();
}
#region IPostBackDataHandler Members
public event EventHandler TextChanged;
public void RaisePostDataChangedEvent()
{
onTextChanged(new EventArgs());
}
protected virtual void onTextChanged(EventArgs e)
{
if(TextChanged !=null)
{
TextChanged(this, e);
}
}
public bool LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection postCollection)
{
string postedValue=postCollection[postDataKey];
string val=Text;
if(val!=postedValue)
{
Text=postedValue;
return true;
}
else
{
return false;
}
}
#endregion
}
[ParseChildren()]
[PersistChildren(false)]
public class cToolRow : WebControl
{
public cToolCell cCell;
public cToolRow():base(HtmlTextWriterTag.Tr)
{}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
writer.AddAttribute(HtmlTextWriterAttribute.Height,"1");
base.AddAttributesToRender (writer);
}
}
[ParseChildren()]
[PersistChildren(false)]
public class cToolCell : WebControl, INamingContainer
{
public cToolCell() : base(HtmlTextWriterTag.Td){}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
base.AddAttributesToRender (writer);
}
}
hidden field (HtmlInputHidden HIH) so that when a button is pressed the
information in the hidden fields value is returned. Somehow, when the
submit button is pressed the value in the Hidden field disappears into cyber
nothing. Please help. This application is supremely important to me.
Anyhow is greatly appreciated thank you
the code is as follows:
public class FreeForm : WebControl, IPostBackDataHandler
{
HtmlGenericControl HGC;
HtmlInputHidden HIH;
public FreeForm(): base(HtmlTextWriterTag.Table)
{}
public string Text
{
get{return HIH.Value;}
set{HIH.Value=value;}
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender (e);
if(!Page.IsClientScriptBlockRegistered("startUp"))
{
StringBuilder jsload=new StringBuilder();
jsload.Append(@"Some javascript not needed here"); // information is
transfered from the div tag to the hidden tag
// using client side code.
string CMSUpReg=jsload.ToString();
Page.RegisterClientScriptBlock("startUp",CMSUpReg);
}
}
protected override void CreateChildControls()
{
Controls.Add(new LiteralControl("<tr bgcolor='#ffffff' height='100%'
width='100%'>"));
Controls.Add(new LiteralControl("<td valign='top'>"));
HIH=new HtmlInputHidden();
HIH.Attributes.Add("value",Text);
HIH.Attributes.Add("name",this.UniqueID);
Controls.Add(HIH);
HGC=new HtmlGenericControl("div");
HGC.Attributes.Add("CONTENTEDITABLE","true");
HGC.Attributes.Add("width","100%");
HGC.Attributes.Add("height","100%");
HGC.Attributes.Add("onBlur","moveCurser(" + HIH.UniqueID + ");");
HGC.Attributes.Add("id","oDiv");
Controls.Add(HGC);
Controls.Add(new LiteralControl("</td>"));
Controls.Add(new LiteralControl("</tr>"));
base.CreateChildControls ();
}
#region IPostBackDataHandler Members
public event EventHandler TextChanged;
public void RaisePostDataChangedEvent()
{
onTextChanged(new EventArgs());
}
protected virtual void onTextChanged(EventArgs e)
{
if(TextChanged !=null)
{
TextChanged(this, e);
}
}
public bool LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection postCollection)
{
string postedValue=postCollection[postDataKey];
string val=Text;
if(val!=postedValue)
{
Text=postedValue;
return true;
}
else
{
return false;
}
}
#endregion
}
[ParseChildren()]
[PersistChildren(false)]
public class cToolRow : WebControl
{
public cToolCell cCell;
public cToolRow():base(HtmlTextWriterTag.Tr)
{}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
writer.AddAttribute(HtmlTextWriterAttribute.Height,"1");
base.AddAttributesToRender (writer);
}
}
[ParseChildren()]
[PersistChildren(false)]
public class cToolCell : WebControl, INamingContainer
{
public cToolCell() : base(HtmlTextWriterTag.Td){}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
base.AddAttributesToRender (writer);
}
}