473,750 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

prerender event

i'm not sure how the preRender event gets handled.

if i have a function:
protected void tbPasswordPreRe nder(object sender, EventArgs e)
{
tbPswd1.Attribu tes["value"] = tbPswd1.Text;
tbPswd2.Attribu tes["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.
--
Share The Knowledge. I need all the help I can get and so do you!
Jun 28 '08 #1
2 2978
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.PreRend er += new EventHandler(tb PasswordPreRend er);
tbPswd2.PreRend er += new EventHandler(tb PasswordPreRend er);
protected void tbPasswordPreRe nder(object sender, EventArgs e)
{
//Use the knowledge that control raising the event is available via
sender argument
TextBox tb=(TextBox)sen der;
tb.Attributes["value"] = tb.Text;
}

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

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"Yankee Imperialist Dog" <Ya************ ******@discussi ons.microsoft.c om>
wrote in message news:DA******** *************** ***********@mic rosoft.com...
i'm not sure how the preRender event gets handled.

if i have a function:
protected void tbPasswordPreRe nder(object sender, EventArgs e)
{
tbPswd1.Attribu tes["value"] = tbPswd1.Text;
tbPswd2.Attribu tes["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.
--
Share The Knowledge. I need all the help I can get and so do you!

Jun 28 '08 #2
thank you for replying,
where in the page cycle should i drop this so that it will call once?

--
Share The Knowledge. I need all the help I can get and so do you!
"Teemu Keiski" wrote:
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.PreRend er += new EventHandler(tb PasswordPreRend er);
tbPswd2.PreRend er += new EventHandler(tb PasswordPreRend er);
protected void tbPasswordPreRe nder(object sender, EventArgs e)
{
//Use the knowledge that control raising the event is available via
sender argument
TextBox tb=(TextBox)sen der;
tb.Attributes["value"] = tb.Text;
}

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

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"Yankee Imperialist Dog" <Ya************ ******@discussi ons.microsoft.c om>
wrote in message news:DA******** *************** ***********@mic rosoft.com...
i'm not sure how the preRender event gets handled.

if i have a function:
protected void tbPasswordPreRe nder(object sender, EventArgs e)
{
tbPswd1.Attribu tes["value"] = tbPswd1.Text;
tbPswd2.Attribu tes["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.
--
Share The Knowledge. I need all the help I can get and so do you!


Jun 29 '08 #3

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

Similar topics

1
1835
by: Alireza Ziai | last post by:
I have problem with prerender event in my page I dont know why prerender event occurs immediatley after Load event , I have same problem with Unload event too ,is it a problem with framework or sth ?
0
1568
by: wardy | last post by:
I've got a .NET web application running in .NET 1.1 on IIS 5 with SQL Server 2000. I've noticed that at times the page rendering is delayed, and when I run the trace I see that the begin prerender event takes anywhere from 0.2-5.0 seconds, whereas all the other events take in the range of 0.000XX seconds. Does anyone know what is happening in the begin prerender event that might be causing this delay (as a note, I've found that when I...
7
4943
by: wardy | last post by:
Hi, I'm hoping someone can lend me a hand....I've got a .NET Web app running on Windows 2000 IIS 5.0 linking to a SQL Server 2000 database. When the database is located on the same server as the web app, the pages render quickly - however, when I run the app with the database on its own server, the page rendering takes anywhere from 5-8 seconds, and when I enable tracing on the application, it appears to be the begin prerender event that...
4
6204
by: Adam Boczek | last post by:
I've a dropdownlist control to change language on my page. Because of page lifetime, I have to set all my labels, texts etc. from ResourceManager in prerender handler to be sure that culture change has been done. But I can't set HeaderText property of DataGridColumn in prerender because it is evaluated during data binding. I don't want to call DataBind() in OnPreRender also... Any ideas? I've tried to walk through Controls collection in...
3
8116
by: Matt Jensen | last post by:
Howdy all - and seasons greetings Just wondering, I've recently discovered the PreRender event for .NET (both for the page and for controls), which seems like a life saver for doing page data loads that need to occur AFTER event handlers have fired, as well as after page load and postback. Is this good, bad or common practice? example I've got a repeater on the page, and in the header of the repeater I've got
1
2707
by: John Dalberg | last post by:
I am trying to send a webpage with datagrids as an email so I use the code snippet below. In one of my datagrids, I reformat some rows in the datagrid's Prerender event. The code behind of the page displays the page and sends the email. The page displays fine however the email has the same look and everything *except* the changes that were made in the grid's prerender. I think I am missing something and was wondering why the changes were...
2
2065
by: Joe | last post by:
Hello All: I have been bitten a few times lately as I've tried to implement functionality in the Page_PreRender event. So here is my question: for what purpose do you use the PreRender event? How do you decide whe to use the PreRender event vs the Unload event? Any respnse will be welcome.
3
8874
by: jc | last post by:
Hello. I have a gridview column item that i want to not make visible if the bound data in that cell is less than a value in a textbox. However, I notice at the time my code checks a function that I call from the visible property of the gridview itemtemplate, the textbox is always blank. I tried setting the textbox in the prerender, but I suspect the
2
6364
by: tshad | last post by:
In VS 2008, I have 2 pages, one aspx page and one ascx page. The PreRender event is not firing on the Contol page. The aspx page starts out: <%@ Page Language="VB" AutoEventWireup="true" Trace="true" CodeFile="TakeSurveyTest.aspx.vb" Inherits="TakeSurveyTest" %> And the ascx page starts out:
1
9338
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6803
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4712
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.