473,397 Members | 1,949 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,397 software developers and data experts.

I need help with OnPreRender

1
I have a web form in which i use OnPreRender to load controls. it works fine BUT no matter what other events I call, the OnPreRender keeps executing. If I click on one of the buttons to fire off the OnClick event, the OnPreRender runs!!! I don't get it. I've never seen this behaviour before. Does anyone have any ideas???


here's part of the class...



namespace mynamespace
{
/// <summary>
/// Summary description for MyClass.
/// </summary>
public class MyClass : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblQM;
protected System.Web.UI.WebControls.Label lblUsers;
protected System.Web.UI.WebControls.DropDownList ddlUsers;
protected System.Web.UI.WebControls.Label lblSelUser;
protected System.Web.UI.WebControls.Button btnAddUser;
protected System.Web.UI.WebControls.Button btnEditUser;
protected System.Web.UI.WebControls.Button btnDeleteUser;
protected System.Web.UI.WebControls.Label lblFirstName;
protected System.Web.UI.WebControls.Label lblLastName;
protected System.Web.UI.WebControls.Label lblUserName;
protected System.Web.UI.WebControls.Label lblPassword;
protected System.Web.UI.WebControls.Label lblUserProfile;
protected System.Web.UI.WebControls.DropDownList ddlUserProfile;
protected System.Web.UI.WebControls.TextBox tbUserFirstName;
protected System.Web.UI.WebControls.TextBox tbUserLastName;
protected System.Web.UI.WebControls.TextBox tbPassword;
protected System.Web.UI.WebControls.TextBox tbUserName;
protected System.Web.UI.WebControls.Button btnGetUserDetails;
protected System.Web.UI.WebControls.Button btnReturnAdminMain;
protected System.Web.UI.WebControls.Label lblPageTitle;

public MyClass()
{

}

private void Page_Load(object sender, System.EventArgs e)
{
// used to add break point
string debugger = "This is just to debug";
}

protected override void OnPreRender( EventArgs e )
{
string Language = Session["language"].ToString();
if (! Page.IsPostBack)
{
string Language = Session["language"].ToString();
lblPageTitle.Text = Localization.GetString(Language,"administration");
lblQM.Text = Localization.GetString(Language, "lblQM");
lblUsers.Text = Localization.GetString(Language, "lblUsers");
lblSelUser.Text = Localization.GetString(Language, "lblSelUser");
btnAddUser.Text = Localization.GetString(Language, "btnAddUser");
btnEditUser.Text = Localization.GetString(Language, "btnEditUser");
btnDeleteUser.Text = Localization.GetString(Language, "btnDeleteUser");
lblFirstName.Text = Localization.GetString(Language, "lblFirstName");
lblLastName.Text = Localization.GetString(Language, "lblLastName");
lblUserName.Text = Localization.GetString(Language, "username");
lblPassword.Text = Localization.GetString(Language, "password");
lblUserProfile.Text = Localization.GetString(Language, "lblUserProfile");
btnReturnAdminMain.Text = Localization.GetString(Language, "btnReturnAdminMain");
btnGetUserDetails.Text = Localization.GetString(Language, "btnGetUserDetails");
}
}

private void btnGetUserDetails_Click(object sender, System.EventArgs e)
{
string testtheclick = "use to test click with break point";

}
}
}
Aug 8 '07 #1
1 1569
nateraaaa
663 Expert 512MB
I have a web form in which i use OnPreRender to load controls. it works fine BUT no matter what other events I call, the OnPreRender keeps executing. If I click on one of the buttons to fire off the OnClick event, the OnPreRender runs!!! I don't get it. I've never seen this behaviour before. Does anyone have any ideas???


here's part of the class...



namespace mynamespace
{
/// <summary>
/// Summary description for MyClass.
/// </summary>
public class MyClass : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblQM;
protected System.Web.UI.WebControls.Label lblUsers;
protected System.Web.UI.WebControls.DropDownList ddlUsers;
protected System.Web.UI.WebControls.Label lblSelUser;
protected System.Web.UI.WebControls.Button btnAddUser;
protected System.Web.UI.WebControls.Button btnEditUser;
protected System.Web.UI.WebControls.Button btnDeleteUser;
protected System.Web.UI.WebControls.Label lblFirstName;
protected System.Web.UI.WebControls.Label lblLastName;
protected System.Web.UI.WebControls.Label lblUserName;
protected System.Web.UI.WebControls.Label lblPassword;
protected System.Web.UI.WebControls.Label lblUserProfile;
protected System.Web.UI.WebControls.DropDownList ddlUserProfile;
protected System.Web.UI.WebControls.TextBox tbUserFirstName;
protected System.Web.UI.WebControls.TextBox tbUserLastName;
protected System.Web.UI.WebControls.TextBox tbPassword;
protected System.Web.UI.WebControls.TextBox tbUserName;
protected System.Web.UI.WebControls.Button btnGetUserDetails;
protected System.Web.UI.WebControls.Button btnReturnAdminMain;
protected System.Web.UI.WebControls.Label lblPageTitle;

public MyClass()
{

}

private void Page_Load(object sender, System.EventArgs e)
{
// used to add break point
string debugger = "This is just to debug";
}

protected override void OnPreRender( EventArgs e )
{
string Language = Session["language"].ToString();
if (! Page.IsPostBack)
{
string Language = Session["language"].ToString();
lblPageTitle.Text = Localization.GetString(Language,"administration");
lblQM.Text = Localization.GetString(Language, "lblQM");
lblUsers.Text = Localization.GetString(Language, "lblUsers");
lblSelUser.Text = Localization.GetString(Language, "lblSelUser");
btnAddUser.Text = Localization.GetString(Language, "btnAddUser");
btnEditUser.Text = Localization.GetString(Language, "btnEditUser");
btnDeleteUser.Text = Localization.GetString(Language, "btnDeleteUser");
lblFirstName.Text = Localization.GetString(Language, "lblFirstName");
lblLastName.Text = Localization.GetString(Language, "lblLastName");
lblUserName.Text = Localization.GetString(Language, "username");
lblPassword.Text = Localization.GetString(Language, "password");
lblUserProfile.Text = Localization.GetString(Language, "lblUserProfile");
btnReturnAdminMain.Text = Localization.GetString(Language, "btnReturnAdminMain");
btnGetUserDetails.Text = Localization.GetString(Language, "btnGetUserDetails");
}
}

private void btnGetUserDetails_Click(object sender, System.EventArgs e)
{
string testtheclick = "use to test click with break point";

}
}
}
Try moving your !Page.IsPostBack conditional statement to your Page_Load Event. I would also recommend placing a breakpoint on each of these methods so that you can be sure how your page is behaving. When you click your button the OnPreRenderEvent should fire first, then the Page_Load, and finally the click event of your button.

Nathan
Aug 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Daniel Groh | last post by:
Hi, i'd like to know more abou this event, i tryed to found in MSDN but the explanation is null for me...is there some explanation when and how should i use it ?
2
by: Sam Samnah | last post by:
I am building a custome control and I need to access the information in the hidden field (HtmlInputHidden HIH) so that when a button is pressed the information in the hidden fields value is...
1
by: Edgardo Rossetto | last post by:
Hello there, I have inserted a UserControl within a DataList: /*------------------------------------------------------------*/ <asp:DataList ID="DataList1" runat="server" DataKeyField="ID"...
3
by: jens.buchta | last post by:
Hi! I'm using a DataGrid with a template column to display an Image inside of it. I'm hooking into its OnPrerender-Event to set the ImageURL-Property dynamically. Everything works just fine...
1
by: bryanp10 | last post by:
I added my own Trace message to the OnPreRender event, and now my trace output is rather interesting: aspx.page Begin PreRender 1.323881 0.000060 OnPreRender start at 9/13/2005...
4
by: Mark Waser | last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a datagrid. In the page PreRender step, the selected index of the datagrid is successfully set during databinding. Yet,...
7
by: ÀÏÆÅ»³ÔÐ5¸öÔ | last post by:
I want use dropdownlist contral in gridview but have trouble now mycode here: i'm very sorry for my poor english <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"...
3
by: John Scott | last post by:
Hey I've got an odd problem here. I have two user controls on a single page. Here is the flow of my page Page(OnLoad) UC1(OnPreRender) UC2(OnPreRender) Page(ButtonClick) UC1(OnPreRender)...
10
by: David Thielen | last post by:
Hi; I have help html pages for each page of my ASP.NET webapp. So for the page datasource.aspx, I have help\datasource.htm. Bu what I want when the hyperlink is clicked, for it to look for the...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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,...

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.