473,320 Members | 2,003 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,320 software developers and data experts.

what does RegisterRequiresPostBack REALLY do??

Sam
According to "Developing Microsoft ASP.NET Server Controls and
Components", a control can get the LoadPostData event by using
RegisterRequiresPostBack, even if its UniqueID does not match that of
the Forms collection.

In the code below, I've tried doing this on a Page instead of a
regular control. However, it doesn't work. The LoadPostData is never
fired, even on postback. Does anyone have any idea why? How could I
make it work for a Page without having to put its UniqueID in the
Forms collection?

As an aside, the Page.ID remained null, even as late as OnPreRender
(that's why I assigned it in OnInit). Does anyone have any ideas
about this as well?

Thanks!!!

-Sam

public class Test : System.Web.UI.Page, IPostBackDataHandler
{
protected Button test;

override protected void OnInit(EventArgs e)
{
this.ID = "page";
test.Text = "Click Me!";
test.Click += new EventHandler(Test_Click);
base.OnInit(e);
}

protected override void OnPreRender(EventArgs e)
{
Page.RegisterRequiresPostBack(this);
base.OnPreRender (e);
}

public void RaisePostDataChangedEvent()
{
}

public bool LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection postCollection)
{
return false;
}

private void Test_Click(object sender, EventArgs e)
{
test.Text = "Clicked!";
}
}
Nov 18 '05 #1
1 1709
It doesn't work for Page, because it is Page itself controlling the postback
data loading for controls. It never tries to to call
IPostBackDataHandler.LoadPostData for itself.

RegisterRequiresPostBack adds the UniqueId of the control to the list of
controls that require postback data handling. At postback it tries to locate
the controls matching this list and call their IPostBackDataHandler
implementation (however, it searches from Page's child controls, therefore
Page itself cannot be found).

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke

"Sam" <sa*******@yahoo.com> wrote in message
news:1a**************************@posting.google.c om...
According to "Developing Microsoft ASP.NET Server Controls and
Components", a control can get the LoadPostData event by using
RegisterRequiresPostBack, even if its UniqueID does not match that of
the Forms collection.

In the code below, I've tried doing this on a Page instead of a
regular control. However, it doesn't work. The LoadPostData is never
fired, even on postback. Does anyone have any idea why? How could I
make it work for a Page without having to put its UniqueID in the
Forms collection?

As an aside, the Page.ID remained null, even as late as OnPreRender
(that's why I assigned it in OnInit). Does anyone have any ideas
about this as well?

Thanks!!!

-Sam

public class Test : System.Web.UI.Page, IPostBackDataHandler
{
protected Button test;

override protected void OnInit(EventArgs e)
{
this.ID = "page";
test.Text = "Click Me!";
test.Click += new EventHandler(Test_Click);
base.OnInit(e);
}

protected override void OnPreRender(EventArgs e)
{
Page.RegisterRequiresPostBack(this);
base.OnPreRender (e);
}

public void RaisePostDataChangedEvent()
{
}

public bool LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection postCollection)
{
return false;
}

private void Test_Click(object sender, EventArgs e)
{
test.Text = "Clicked!";
}
}

Nov 18 '05 #2

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

Similar topics

92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
7
by: steve bull | last post by:
I have the following code snippet to read the colorRange attributes for the colorRangeSwatch in the xml file listed below. string expr = "/swatches/colorRangeSwatch/colorRange";...
44
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there...
35
by: GTO | last post by:
I do not believe that C# is the future of C++. I also do not believe that adding two thousand new library functions to the standard library is the future of C++. But what is the future of C++? Is...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
24
by: Bob Alston | last post by:
Most of my Access database implementations have been fairly small in terms of data volume and number of concurrent users. So far I haven't had performance issues to worry about. <knock on wood> ...
21
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.