Hello.
I wrote a Web Custom Control that have a property named SelectedValue. This SelectedValue property is set after the user clicks a LinkButton control, by its Click() event.
I did some tests, and I noticed that my handled LinkButton_Clic k() event is fired only after the Page_Load() event, due to page and control lifecicles.
The result of this is, when in Page_Load(), I can only catch the SelectedValue from a previous postback (out of sync).
BUT.... I know and yet did a test with a RadioButtonList . I can retrieve the updated SelectedValue in the Page_Load event with no problem!!
Anyone know the trick so I can update my SelectedValue before the Page_Load() event, soon after the user clicks a LinkButton?
Example (just relevant pieces - better viewed in RichText format):
WebCustomContro l:
'retrieves from/sets to viewstate. This property is started with zero ("0")
<DefaultValue(F alse), Browsable(False )_
Public Property SelectedValue() As Integer
Get
Return CInt(ViewStateC lass.Retrieve(V iewState, "SelectedValue" , "0"))
End Get
Set(ByVal value As Integer)
ViewStateClass. Save(ViewState, "SelectedValue" , CInt(value))
End Set
End Property
'this is where I set the SelectedValue (this event was previously attached via AddHandler)
Private Sub LinkButtonClick (ByVal sender As Object, ByVal e As System.EventArg s)
Me.SelectedValu e = lnk.CommandArgu ment
End Sub
Page:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
Label1.Text = MyControl.Selec tedValue '<= on first postback, it returns "0", even
'if the user clicks a LinkButton that returns 20. On second postback, that 20 will
'be returned. Or shortly, it is out of sync.
End Sub 3 1889
"ronchese" <info(a)carsoft net.com.brwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Hello.
I wrote a Web Custom Control that have a property named SelectedValue. This
SelectedValue property is set after the user clicks a LinkButton control, by
its Click() event.
I did some tests, and I noticed that my handled LinkButton_Clic k() event is
fired only after the Page_Load() event, due to page and control lifecicles.
The result of this is, when in Page_Load(), I can only catch the
SelectedValue from a previous postback (out of sync).
BUT.... I know and yet did a test with a RadioButtonList . I can retrieve the
updated SelectedValue in the Page_Load event with no problem!!
Anyone know the trick so I can update my SelectedValue before the
Page_Load() event, soon after the user clicks a LinkButton? http://www.15seconds.com/issue/020102.htm
I don't know. Maybe using a Session variable and understanding the ASP.NET
Page Life Cycle and where you can possibly intercept things.
As I understood, even a session variable can itself solve this problem.
It is because the LinkButton_Clic k() event is raised *after* the Page_Load()
event.
I guess there is a switch or a trick to resolve this.
As MSDN says, Control Events are raised after Page Load: http://msdn2.microsoft.com/en-us/library/ms178472.aspx
I'm thirsty to find the trick :P
"Mr. Arnold" <MR. Ar****@Arnold.c omwrote in message
news:eE******** ******@TK2MSFTN GP03.phx.gbl...
>
"ronchese" <info(a)carsoft net.com.brwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Hello.
I wrote a Web Custom Control that have a property named SelectedValue.
This SelectedValue property is set after the user clicks a LinkButton
control, by its Click() event.
I did some tests, and I noticed that my handled LinkButton_Clic k() event
is fired only after the Page_Load() event, due to page and control
lifecicles.
The result of this is, when in Page_Load(), I can only catch the
SelectedValue from a previous postback (out of sync).
BUT.... I know and yet did a test with a RadioButtonList . I can retrieve
the updated SelectedValue in the Page_Load event with no problem!!
Anyone know the trick so I can update my SelectedValue before the
Page_Load() event, soon after the user clicks a LinkButton?
http://www.15seconds.com/issue/020102.htm
I don't know. Maybe using a Session variable and understanding the ASP.NET
Page Life Cycle and where you can possibly intercept things.
Guess I found the trick. It is a workaround, but it works. http://devsushi.com/2006/09/01/aspne...ntrols-part-2/
[]s
Cesar
"ronchese" <info(a)carsoft net.com.brwrote in message
news:Ol******** ******@TK2MSFTN GP05.phx.gbl...
As I understood, even a session variable can itself solve this problem.
It is because the LinkButton_Clic k() event is raised *after* the
Page_Load() event.
I guess there is a switch or a trick to resolve this.
As MSDN says, Control Events are raised after Page Load: http://msdn2.microsoft.com/en-us/library/ms178472.aspx
I'm thirsty to find the trick :P
"Mr. Arnold" <MR. Ar****@Arnold.c omwrote in message
news:eE******** ******@TK2MSFTN GP03.phx.gbl...
>> "ronchese" <info(a)carsoft net.com.brwrote in message news:%2******* *********@TK2MS FTNGP04.phx.gbl ... Hello.
I wrote a Web Custom Control that have a property named SelectedValue. This SelectedValue property is set after the user clicks a LinkButton control, by its Click() event.
I did some tests, and I noticed that my handled LinkButton_Clic k() event is fired only after the Page_Load() event, due to page and control lifecicles.
The result of this is, when in Page_Load(), I can only catch the SelectedValu e from a previous postback (out of sync).
BUT.... I know and yet did a test with a RadioButtonList . I can retrieve the updated SelectedValue in the Page_Load event with no problem!!
Anyone know the trick so I can update my SelectedValue before the Page_Load() event, soon after the user clicks a LinkButton?
http://www.15seconds.com/issue/020102.htm
I don't know. Maybe using a Session variable and understanding the ASP.NET Page Life Cycle and where you can possibly intercept things.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jay Walker |
last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN
Article:
Creating Custom Columns for the ASP.NET Datagrid
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/creatingcustomcolumns.asp
The problem I am having is that the data in the custom datagridcolumn
is not saved to viewstate and after postback, the column does not
contain data.
|
by: John Lau |
last post by:
Hi,
Is there documentation that talks about the page lifecycle, the lifecycle of
controls on the page, and the rendering of inline code, in a single
document?
Thanks,
John
|
by: sqlboy2000 |
last post by:
Hello all,
I have something very simple going on here and I'm scratching my head
as to what the problem is. There are 4 items in my project, 2 webforms,
a user control, and a module:
WebForm1.aspx
ChangeValue.aspx
WebUserControl1.ascx
Module1.vb
|
by: fwirtanen |
last post by:
I am building a custom composite control consisting of two drop downs,
with parent/child dependancy.
The child dropdownlist is updated through client callback when the
parent index changes.
An 'All' list item is added to the child dropdown during the
CreateControlHeirarchy(bool useDataSource) method.
Somewhere between the CreateControlHeirarchy method executing and the
|
by: Jaybuffet |
last post by:
my aspx has something like this
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>'
showItem="true"/>
</ItemTemplate>
/asp:Repeater>
The DataSource for this Repeater is a CollectionBase of objects and is
| |
by: =?Utf-8?B?TWFyayBHaWxrZXM=?= |
last post by:
I have designed and written a custom menu like server control. The control
inherits from DataBoundControl and implements INamingContainer and
IPostBackEventHandler interfaces. The control uses only html mark-up as it’s
UI, i.e. tables, table rows and table cells, and no intrinsic html controls
such as input or select. The control does not implement any client-side
script and therefore redraws its updated UI on postback through the...
|
by: Michal Valent |
last post by:
I would like to fire some custom server control event before Page_Load event
like this (from the trace of an aspx page) :
Trace Information
Category Message From First(s) From Last(s)
aspx.page Begin PreInit
aspx.page End PreInit 5,38454603734274E-05 0,000054
aspx.page Begin Init 8,96405962016187E-05 0,000036
aspx.page End Init 0,00072941040948794 0,000640
aspx.page Begin InitComplete 0,000772971258380746 0,000044
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge.
I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge.
I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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...
|
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();...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |