I need help badly

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);
}
}
 
I

intrader

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);
}
}
Perhaps if you reload the hidden field from its value in ViewState.
 
S

Sam Samnah

I tried that. It does the same thing.
intrader said:
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);
}
}
Perhaps if you reload the hidden field from its value in ViewState.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top