About the "Page.RegisterRequiresRaiseEvent and Page.RequiresPostBa

H

han zhiyang

I wonder if the Page.RegisterRequiresRaiseEvent and Page.RequiresPostBack are
asp.net bugs,for they are somewhat "ugly" and difficult to use.At the same
time, I wonder if there is other alternatives I can choose.I've read the book
"Developing Microsoft ASP.NET Server Controls and Components" by Nikhil
Kothari, and here is some codes in LoadPostData method in code list 9-11:

bool buttonClicked = (buttonValue != null) && (buttonValue.Length != 0);
if (buttonClicked) Page.RegisterRequiresRaiseEvent(this);

Reading these codes,I feel I go back to the asp times again. these are
somewhat ugly.
 
T

Teemu Keiski

Well,

how would you do it better? Please share as that would ne crucial
information for MS to make the ASP.NET even better.

Personally, I find those methods useful and not so hard to use, especially
thanks to Nikhil's book, but sure everything can always be implemented
better.

That line of code is because implementing IPostBackDataHandler goes over
IPostBackEventhandler when control's implementation is checked (postback
data checked and determined what interface implementation to call) so when
control implements both interfaces, IPostBackEventHandler implementation
must be manually called since framework deals then only with
IPostBackDataHandler
 
T

Teemu Keiski

And by the way, in ASP.NET v2 their use is not so crucial as Framework is
smarter in calling both event implementations. That's just based on my
tests.

Teemu
 
H

han zhiyang

Thank you very much for your Response.
I read the version1.1 SDK,and tried to use a submit button named with the
UniqueID of my custom control.i had thought the control on server side and
the html tags rendered by it are two different entity,so the asp.net runtime
may find the UniqueID in submited contents and also can find the custom
control with the same UniqueID in the requested page.because the latter has
inherited those two interfaces,so the expected methods could work. but i
failed and don't know why. I've implemented the LoadPostData and
RaisePostBackEvent method according to the instructions in Nikhil's book.It
is really not so difficult to use and works pretty well,although still it
seems not so elegant.
say thank you again.
 
H

han zhiyang

By the way,the submit button is rendered in the custom control's Render method.
 

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,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top