Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2008

Tip: Looking for answers? Try searching our database.

prerender event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Yankee Imperialist Dog - 28 Jun 2008 18:51 GMT
i'm not sure how the preRender event gets handled.

if i have a function:
   protected void tbPasswordPreRender(object sender, EventArgs e)
   {
       tbPswd1.Attributes["value"] = tbPswd1.Text;
       tbPswd2.Attributes["value"] = tbPswd2.Text;
   }
and set the two text boxes Prerender event to this single function will it
fire twice?
I'm hoping that dot.net is smart enough to do it oncelike the way sqlserver
handles some sub queries.
Signature

Share The Knowledge. I need all the help I can get and so do you!

Teemu Keiski - 28 Jun 2008 22:29 GMT
Hi,

if it is wired to two controls, it will run twice, no question about that -
this has nothing to do with SQL Server's subqueries :-). Controls do not
know about each other unless it is explicitly somehow stated by the page
developer. Controls cannot assume much about logic - like the logic run on
their Prerender event , as the assumption could be wrong, too.

Instead of hardcoding the controls in the event handler, you could rely on
event being raised for specific control and deal with only it.

You could for example run it like this:

//Wiring events somewhere
tbPswd1.PreRender += new EventHandler(tbPasswordPreRender);
tbPswd2.PreRender += new EventHandler(tbPasswordPreRender);

 protected void tbPasswordPreRender(object sender, EventArgs e)
   {
       //Use the knowledge that control raising the event is available via
sender argument
       TextBox tb=(TextBox)sender;
       tb.Attributes["value"] = tb.Text;
   }

When it works equally for all TextBoxes you assign this handler to.

Signature

Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

> i'm not sure how the preRender event gets handled.
>
[quoted text clipped - 9 lines]
> sqlserver
> handles some sub queries.
Yankee Imperialist Dog - 29 Jun 2008 23:31 GMT
thank you for replying,
where in the page cycle should i drop this so that it will call once?

Signature

Share The Knowledge. I need all the help I can get and so do you!

> Hi,
>
[quoted text clipped - 36 lines]
> > sqlserver
> > handles some sub queries.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.