473,394 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

IPostBackDataHandler problem

Hi,

Im developing a RibbonBar Control in asp.net 1.1 by converting already
done in asp.net 2.0.
My problem is that theres no compositecontrol in 1.1. Correct me if im
wrong, heres what i want to achieve.

My RibbonButton control is a regular webcontrol. RibbonButton
instantiates a hiddenfield inside by creating new instance. So we have
simple situation here wheres RibbonControl that contains hiddenfield
control inside.
Note that aps.net 1.1 does not have hidden fields so i created my own
listed below:

public class SharedStateHiddenField : WebControl, IPostBackDataHandler
{
public string Value
{
get { return ViewState["Value"] != null ? (string)ViewState["Value"]
: string.Empty; }
set { ViewState["Value"] = value; }
}

protected override void AddAttributesToRender(HtmlTextWriter writer)
{
writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
writer.AddAttribute(HtmlTextWriterAttribute.Name, ClientID);
writer.AddAttribute(HtmlTextWriterAttribute.Value, Value);
writer.AddAttribute(HtmlTextWriterAttribute.Type, "hidden");
}

protected override HtmlTextWriterTag TagKey
{
get
{
return HtmlTextWriterTag.Input;
}
}
#region IPostBackDataHandler Members

public void RaisePostDataChangedEvent()
{

}

bool IPostBackDataHandler.LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection values)
{
return LoadPostData(postDataKey, values);
}
protected virtual bool LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection values)
{
string val = values[this.ClientID];
bool changed = false;
if (val != Value)
{
Value = val;
changed = true;
}
return changed;
}

#endregion
}
}

So, when i do postback on whatever control on my page, this
IPostBackDataHandler in my hidden field is not fired !

i want it to be fired and thats my question, why ?

Do you possibly know what is wrong ?

regards, Peter
Sep 5 '07 #1
4 1818
My problem is that theres no compositecontrol in 1.1. Correct me if im
wrong, heres what i want to achieve.
Composite controls come from 1.xx . Try this:
http://www.microsoft.com/MSPress/books/5728.aspx
Cheers
Smith
Sep 5 '07 #2
Smith pisze:
>My problem is that theres no compositecontrol in 1.1. Correct me if im
wrong, heres what i want to achieve.

Composite controls come from 1.xx . Try this:
http://www.microsoft.com/MSPress/books/5728.aspx
Cheers
Smith

Ok Found the problem.
I used clientId instead of uniqueId property, ma fault.

here's the correct code for hiddenfield control in asp.net 1.1 :)

public class SharedStateHiddenField : WebControl, IPostBackDataHandler
{
public string Value
{
get { return ViewState["Value"] != null ? (string)ViewState["Value"]
: string.Empty; }
set { ViewState["Value"] = value; }
}

protected override void AddAttributesToRender(HtmlTextWriter writer)
{
writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);
writer.AddAttribute(HtmlTextWriterAttribute.Value, Value);
writer.AddAttribute(HtmlTextWriterAttribute.Type, "hidden");
}

protected override HtmlTextWriterTag TagKey
{
get
{
return HtmlTextWriterTag.Input;
}
}
#region IPostBackDataHandler Members

public void RaisePostDataChangedEvent()
{

}

bool IPostBackDataHandler.LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection values)
{
return LoadPostData(postDataKey, values);
}
protected virtual bool LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection values)
{
string val = values[this.UniqueID];
bool changed = false;
if (val != Value)
{
Value = val;
changed = true;
}
return changed;
}

#endregion
}
Sep 5 '07 #3


"Piotr Nowak" <p.******@STRIPTHISwasko.plwrote in message
news:fb**********@atlantis.news.tpi.pl...
Note that aps.net 1.1 does not have hidden fields so i created my own
listed below:

What do you mean 1.1 doesn't have hidden fields?!? Check out the
System.Web.UI.HtmlControls namespace and look for the HtmlInputHidden
control. :)

HTH,
Mythran
Sep 5 '07 #4
Mythran pisze:
>

"Piotr Nowak" <p.******@STRIPTHISwasko.plwrote in message
news:fb**********@atlantis.news.tpi.pl...
>Note that aps.net 1.1 does not have hidden fields so i created my own
listed below:


What do you mean 1.1 doesn't have hidden fields?!? Check out the
System.Web.UI.HtmlControls namespace and look for the HtmlInputHidden
control. :)

HTH,
Mythran

oh, right :)
i think i was suggested by some news article saying that asp.net 2.0 has
some new features like the new HiddenField component.

anyway, thanks :)
Sep 6 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
0
by: One Handed Man \( OHM - Terry Burns \) | last post by:
I have implemented the System.Web.UI.IPostBackDataHandler.LoadPostData interface in my custom control, however, when I submit this Function is not called by ASP.NET ( Which is what I assume is...
6
by: Francois | last post by:
Hi, I am trying to implement a custom control that extends the standard System.Web.UI.WebControls.CheckBox control. In the .Net class library reference it is said that CheckBox Implements...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
9
by: brian.mills | last post by:
I've been building some custom controls which have some special functionality with the data I use from a web service, specifically the ability to data bind to attributes (without an accessor...
1
by: z f | last post by:
Hi. How can I make a custom control in VB.NET that is inheriting from TextBox and also implements/inherits the IPostBackDataHandler? the problem is that in VB.NET I can't inherit from more that...
0
by: Martin Gustavsson | last post by:
I'm a bit puzzled by the IPostBackDataHandler. What if i have a custom control that I render myself, and I render 30 input-fields. They can't all have the name of the control's UniqueID? Which is...
4
by: Nathan Sokalski | last post by:
During my postbacks, I try to assign the value from an Input tag to a property of a custom control. However, I keep recieving the following error: An exception of type...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.