Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Igor #1
Events Handling Order
Hi all,
I'm a total newbie, so this might be stupid...
Anyway, I've created an expanding tree of categories control, based on
DataList.
It works almost fine, but I can't make it return the value of the last
category clicked.
To be more specific, it does return it, but only the second time I click the
category.
For example, if I click category 5 and then 8, it shows 5 and clicking later
on 3 shows 8.
It goes like this:
..
..
..
public property CategoryID
Get
if(ViewState("CurrentCategory") = Nothing)
CategoryID = 1
else
CategoryID = ViewState("CurrentCategory").ToString
end if
End Get
Set
ViewState("CurrentCategory") = value
End Set
end property
..
..
..
sub CategoriesDataList_ItemCommand(sender As Object, e as
DataListCommandEventArgs)
CategoryID = e.CommandArgument
CategoriesDataList.DataSource = GetCategoriesTree(e.CommandArgument)
DataBind
CategoriesDataList.SelectedIndex = e.Item.ItemIndex
End Sub
The real big problem, as much as I could figure it out is that the
CategoriesDataList_ItemCommand event is processed AFTER the Page_Load event
of the parent page is. So, when i write something like
[assume CategoriesTree is a CategoriesDataList control]
msg.Text = CategoriesTree.CategoryID
in the parent page, the value shown in msg is the old one (taken from
ViewState bag).
Thanks for any help,
Igor.
Igor Guest
-
Order of events
I have a form with several controls on it, one control has a drop down list. When a user selects an item in that drop down list, I want everything... -
(vb.net) Handling user-control events
I created a web-project containg an .aspx file and a self- made User-Control (.acsx file) - all in vb.net. My aspx file contains a Submit button... -
Handling events in container controls?
Hi, I have a sub in a user control that looks like this: Public Sub BatchDetail_ItemCommand(ByVal Sender As Object, ByVal e As... -
Handling events in a datagrid
Hi, I am having a datagrid with 3 radiobuttons in one template column and a textbox in another template column. How can I disable or enable the... -
Handling Events in Nested Controls
Hi, I have nested User Controls like below. User_Control_1 User_Control_11 User_Control_12(contains method DisplayMessage) ... -
Victor Garcia Aprea #2
Re: Events Handling Order
Hi Igor,
If you need to handle values that will be updated by a click events use an
event that fires *after* the handling of click events, i.e.: PreRender. As
you've discovered the Load event fires *before* the handling of events so
you can't count on such values to be updated at that point.
--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
[url]http://obies.com/vga/blog.aspx[/url]
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
"Igor" <IgorRubinovich@yahoo.com> wrote in message
news:3a4989f7.0311251704.5efb91be@posting.google.c om...the> Hi all,
> I'm a total newbie, so this might be stupid...
> Anyway, I've created an expanding tree of categories control, based on
> DataList.
> It works almost fine, but I can't make it return the value of the last
> category clicked.
> To be more specific, it does return it, but only the second time I clicklater> category.
> For example, if I click category 5 and then 8, it shows 5 and clickingevent> on 3 shows 8.
>
> It goes like this:
>
> .
> .
> .
> public property CategoryID
> Get
> if(ViewState("CurrentCategory") = Nothing)
> CategoryID = 1
> else
> CategoryID = ViewState("CurrentCategory").ToString
> end if
> End Get
> Set
>
> ViewState("CurrentCategory") = value
> End Set
> end property
>
> .
> .
> .
>
> sub CategoriesDataList_ItemCommand(sender As Object, e as
> DataListCommandEventArgs)
> CategoryID = e.CommandArgument
> CategoriesDataList.DataSource = GetCategoriesTree(e.CommandArgument)
> DataBind
> CategoriesDataList.SelectedIndex = e.Item.ItemIndex
> End Sub
>
> The real big problem, as much as I could figure it out is that the
> CategoriesDataList_ItemCommand event is processed AFTER the Page_Load> of the parent page is. So, when i write something like
>
> [assume CategoriesTree is a CategoriesDataList control]
>
> msg.Text = CategoriesTree.CategoryID
>
> in the parent page, the value shown in msg is the old one (taken from
> ViewState bag).
>
>
> Thanks for any help,
> Igor.
Victor Garcia Aprea Guest



Reply With Quote

