473,725 Members | 2,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

event handling in a user control

Hi,

I have created a web page which includes a place holder. I also have a
dropdown list in that webpage. when I select one of the choices in that
dropdown list, It will load a user control into the place holder. This is
done dynamically based on the choice they selected. This user control has a
datagrid in it that supports paging. When I click on the next or prev buttons
of the datagrid in a user control it should display the next page results.
but it is not doing so. I am not knowing how to call the PageIndexChange d
event of the user control from the webpage. could anyone show me a code
sample to do that? I am using VB.NET for this.

Thanks,
Sridhar.
Nov 20 '05 #1
9 2334
Dynamically loading controls must be done during the Page.Init event handling
(page initialization stage) otherwise they would lose they ViewState and
their events would not fire. So if you added a control based on a
SelectedIndexCh anged, it is added late in the page lifecycle and you have to
persist a condition that allows you to reload it during the page.init event
handling, otherwise no response would happen to any of its events.

For a simple demo on this concept:
http://www.societopia.net/Samples/Dy...dControls.aspx

For a clear explanation of the page life cycle:
http://msdn.microsoft.com/library/de.../viewstate.asp

--
[note: if this post answers your question, you can mark it as an answer
using the web-based newsreader functions]
-----
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Sridhar" wrote:
Hi,

I have created a web page which includes a place holder. I also have a
dropdown list in that webpage. when I select one of the choices in that
dropdown list, It will load a user control into the place holder. This is
done dynamically based on the choice they selected. This user control has a
datagrid in it that supports paging. When I click on the next or prev buttons
of the datagrid in a user control it should display the next page results.
but it is not doing so. I am not knowing how to call the PageIndexChange d
event of the user control from the webpage. could anyone show me a code
sample to do that? I am using VB.NET for this.

Thanks,
Sridhar.

Nov 20 '05 #2
Dynamically added controls need to be readded on postback. If you don't
add it back, how can an event ever be fired for it, it doesn't exist!.

You can use Denis Bauer's DynamicControls Placeholder (free):
http://www.denisbauer.com/ASPNETCont...aceholder.aspx
which automatically re-adds dynamic controls on postback, or you can do it
yourself. Here's a dummy example:

sub Page_Load()
if Page.IsPostBack AndAlso not ViewState("cont rolToReload) is nothing then
plc.Controls.Ad d(cstr(ViewStat e(controlPath)) )
end if
end sub

sub selectedindexch ange(..)
string controlPath = "mycontrol.ascx "
plc.Controls.Ad d(Page.LoadCont rol(controlPath ))
ViewState.Add(" controlToReload ", controlPath)
end sub
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
news:A2******** *************** ***********@mic rosoft.com...
Hi,

I have created a web page which includes a place holder. I also have a
dropdown list in that webpage. when I select one of the choices in that
dropdown list, It will load a user control into the place holder. This is
done dynamically based on the choice they selected. This user control has
a
datagrid in it that supports paging. When I click on the next or prev
buttons
of the datagrid in a user control it should display the next page results.
but it is not doing so. I am not knowing how to call the PageIndexChange d
event of the user control from the webpage. could anyone show me a code
sample to do that? I am using VB.NET for this.

Thanks,
Sridhar.

Nov 20 '05 #3
Philip:
This question gets asked all the time, imma keep ur links and pass them off
as my own helpfulness next time! HAR!

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Phillip Williams" <Ph************ **@webswapp.com > wrote in message
news:A1******** *************** ***********@mic rosoft.com...
Dynamically loading controls must be done during the Page.Init event
handling
(page initialization stage) otherwise they would lose they ViewState and
their events would not fire. So if you added a control based on a
SelectedIndexCh anged, it is added late in the page lifecycle and you have
to
persist a condition that allows you to reload it during the page.init
event
handling, otherwise no response would happen to any of its events.

For a simple demo on this concept:
http://www.societopia.net/Samples/Dy...dControls.aspx

For a clear explanation of the page life cycle:
http://msdn.microsoft.com/library/de.../viewstate.asp

--
[note: if this post answers your question, you can mark it as an answer
using the web-based newsreader functions]
-----
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Sridhar" wrote:
Hi,

I have created a web page which includes a place holder. I also have a
dropdown list in that webpage. when I select one of the choices in that
dropdown list, It will load a user control into the place holder. This
is
done dynamically based on the choice they selected. This user control has
a
datagrid in it that supports paging. When I click on the next or prev
buttons
of the datagrid in a user control it should display the next page
results.
but it is not doing so. I am not knowing how to call the PageIndexChange d
event of the user control from the webpage. could anyone show me a code
sample to do that? I am using VB.NET for this.

Thanks,
Sridhar.

Nov 20 '05 #4
Hi
Thanks for the reply. But the problem is I am getting the control name
dynamically and loading it dynamically. In that case how would I know which
events shoud I add?

Thanks,
Sridhar.

"Phillip Williams" wrote:
Dynamically loading controls must be done during the Page.Init event handling
(page initialization stage) otherwise they would lose they ViewState and
their events would not fire. So if you added a control based on a
SelectedIndexCh anged, it is added late in the page lifecycle and you have to
persist a condition that allows you to reload it during the page.init event
handling, otherwise no response would happen to any of its events.

For a simple demo on this concept:
http://www.societopia.net/Samples/Dy...dControls.aspx

For a clear explanation of the page life cycle:
http://msdn.microsoft.com/library/de.../viewstate.asp

--
[note: if this post answers your question, you can mark it as an answer
using the web-based newsreader functions]
-----
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Sridhar" wrote:
Hi,

I have created a web page which includes a place holder. I also have a
dropdown list in that webpage. when I select one of the choices in that
dropdown list, It will load a user control into the place holder. This is
done dynamically based on the choice they selected. This user control has a
datagrid in it that supports paging. When I click on the next or prev buttons
of the datagrid in a user control it should display the next page results.
but it is not doing so. I am not knowing how to call the PageIndexChange d
event of the user control from the webpage. could anyone show me a code
sample to do that? I am using VB.NET for this.

Thanks,
Sridhar.

Nov 20 '05 #5
If your control is an ascx that you load using the LoadControl method
http://msdn.microsoft.com/library/de...ntroltopic.asp
then you have to redo that LoadControl method in the Page_init upon postback.
This should take care of the all the event handling that you have defined in
your ascx control.
--
[note: if this post answers your question, you can mark it as an answer
using the web-based newsreader functions]
-----
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Sridhar" wrote:
Hi
Thanks for the reply. But the problem is I am getting the control name
dynamically and loading it dynamically. In that case how would I know which
events shoud I add?

Thanks,
Sridhar.

"Phillip Williams" wrote:
Dynamically loading controls must be done during the Page.Init event handling
(page initialization stage) otherwise they would lose they ViewState and
their events would not fire. So if you added a control based on a
SelectedIndexCh anged, it is added late in the page lifecycle and you have to
persist a condition that allows you to reload it during the page.init event
handling, otherwise no response would happen to any of its events.

For a simple demo on this concept:
http://www.societopia.net/Samples/Dy...dControls.aspx

For a clear explanation of the page life cycle:
http://msdn.microsoft.com/library/de.../viewstate.asp

--
[note: if this post answers your question, you can mark it as an answer
using the web-based newsreader functions]
-----
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Sridhar" wrote:
Hi,

I have created a web page which includes a place holder. I also have a
dropdown list in that webpage. when I select one of the choices in that
dropdown list, It will load a user control into the place holder. This is
done dynamically based on the choice they selected. This user control has a
datagrid in it that supports paging. When I click on the next or prev buttons
of the datagrid in a user control it should display the next page results.
but it is not doing so. I am not knowing how to call the PageIndexChange d
event of the user control from the webpage. could anyone show me a code
sample to do that? I am using VB.NET for this.

Thanks,
Sridhar.

Nov 20 '05 #6
Hi Karl,

Yes you are right regarding this question being frequently asked. (I am
sorry I did not understand the abbreviations you used in your post: imma and
HAR)

Regards,

Phillip

"Karl Seguin" wrote:
Philip:
This question gets asked all the time, imma keep ur links and pass them off
as my own helpfulness next time! HAR!

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Phillip Williams" <Ph************ **@webswapp.com > wrote in message
news:A1******** *************** ***********@mic rosoft.com...
Dynamically loading controls must be done during the Page.Init event
handling
(page initialization stage) otherwise they would lose they ViewState and
their events would not fire. So if you added a control based on a
SelectedIndexCh anged, it is added late in the page lifecycle and you have
to
persist a condition that allows you to reload it during the page.init
event
handling, otherwise no response would happen to any of its events.

For a simple demo on this concept:
http://www.societopia.net/Samples/Dy...dControls.aspx

For a clear explanation of the page life cycle:
http://msdn.microsoft.com/library/de.../viewstate.asp

--
[note: if this post answers your question, you can mark it as an answer
using the web-based newsreader functions]
-----
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Sridhar" wrote:
Hi,

I have created a web page which includes a place holder. I also have a
dropdown list in that webpage. when I select one of the choices in that
dropdown list, It will load a user control into the place holder. This
is
done dynamically based on the choice they selected. This user control has
a
datagrid in it that supports paging. When I click on the next or prev
buttons
of the datagrid in a user control it should display the next page
results.
but it is not doing so. I am not knowing how to call the PageIndexChange d
event of the user control from the webpage. could anyone show me a code
sample to do that? I am using VB.NET for this.

Thanks,
Sridhar.


Nov 20 '05 #7
Thank you so much. It is working now.

"Karl Seguin" wrote:
Dynamically added controls need to be readded on postback. If you don't
add it back, how can an event ever be fired for it, it doesn't exist!.

You can use Denis Bauer's DynamicControls Placeholder (free):
http://www.denisbauer.com/ASPNETCont...aceholder.aspx
which automatically re-adds dynamic controls on postback, or you can do it
yourself. Here's a dummy example:

sub Page_Load()
if Page.IsPostBack AndAlso not ViewState("cont rolToReload) is nothing then
plc.Controls.Ad d(cstr(ViewStat e(controlPath)) )
end if
end sub

sub selectedindexch ange(..)
string controlPath = "mycontrol.ascx "
plc.Controls.Ad d(Page.LoadCont rol(controlPath ))
ViewState.Add(" controlToReload ", controlPath)
end sub
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
news:A2******** *************** ***********@mic rosoft.com...
Hi,

I have created a web page which includes a place holder. I also have a
dropdown list in that webpage. when I select one of the choices in that
dropdown list, It will load a user control into the place holder. This is
done dynamically based on the choice they selected. This user control has
a
datagrid in it that supports paging. When I click on the next or prev
buttons
of the datagrid in a user control it should display the next page results.
but it is not doing so. I am not knowing how to call the PageIndexChange d
event of the user control from the webpage. could anyone show me a code
sample to do that? I am using VB.NET for this.

Thanks,
Sridhar.


Nov 20 '05 #8
imma = im going to
and HAR is my pirate laugh...HAR HAR!

Karl ;)

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Phillip Williams" <Ph************ **@webswapp.com > wrote in message
news:A9******** *************** ***********@mic rosoft.com...
Hi Karl,

Yes you are right regarding this question being frequently asked. (I am
sorry I did not understand the abbreviations you used in your post: imma
and
HAR)

Regards,

Phillip

"Karl Seguin" wrote:
Philip:
This question gets asked all the time, imma keep ur links and pass them
off
as my own helpfulness next time! HAR!

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Phillip Williams" <Ph************ **@webswapp.com > wrote in message
news:A1******** *************** ***********@mic rosoft.com...
> Dynamically loading controls must be done during the Page.Init event
> handling
> (page initialization stage) otherwise they would lose they ViewState
> and
> their events would not fire. So if you added a control based on a
> SelectedIndexCh anged, it is added late in the page lifecycle and you
> have
> to
> persist a condition that allows you to reload it during the page.init
> event
> handling, otherwise no response would happen to any of its events.
>
> For a simple demo on this concept:
> http://www.societopia.net/Samples/Dy...dControls.aspx
>
> For a clear explanation of the page life cycle:
> http://msdn.microsoft.com/library/de.../viewstate.asp
>
> --
> [note: if this post answers your question, you can mark it as an answer
> using the web-based newsreader functions]
> -----
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Sridhar" wrote:
>
>> Hi,
>>
>> I have created a web page which includes a place holder. I also have
>> a
>> dropdown list in that webpage. when I select one of the choices in
>> that
>> dropdown list, It will load a user control into the place holder.
>> This
>> is
>> done dynamically based on the choice they selected. This user control
>> has
>> a
>> datagrid in it that supports paging. When I click on the next or prev
>> buttons
>> of the datagrid in a user control it should display the next page
>> results.
>> but it is not doing so. I am not knowing how to call the
>> PageIndexChange d
>> event of the user control from the webpage. could anyone show me a
>> code
>> sample to do that? I am using VB.NET for this.
>>
>> Thanks,
>> Sridhar.


Nov 20 '05 #9
No piracy at all. :-) I believe all information posted on the newsgroup is
free to share. You are quite welcome to do so.

Regards,
Phillip

"Karl Seguin" wrote:
imma = im going to
and HAR is my pirate laugh...HAR HAR!

Karl ;)

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Phillip Williams" <Ph************ **@webswapp.com > wrote in message
news:A9******** *************** ***********@mic rosoft.com...
Hi Karl,

Yes you are right regarding this question being frequently asked. (I am
sorry I did not understand the abbreviations you used in your post: imma
and
HAR)

Regards,

Phillip

"Karl Seguin" wrote:
Philip:
This question gets asked all the time, imma keep ur links and pass them
off
as my own helpfulness next time! HAR!

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Phillip Williams" <Ph************ **@webswapp.com > wrote in message
news:A1******** *************** ***********@mic rosoft.com...
> Dynamically loading controls must be done during the Page.Init event
> handling
> (page initialization stage) otherwise they would lose they ViewState
> and
> their events would not fire. So if you added a control based on a
> SelectedIndexCh anged, it is added late in the page lifecycle and you
> have
> to
> persist a condition that allows you to reload it during the page.init
> event
> handling, otherwise no response would happen to any of its events.
>
> For a simple demo on this concept:
> http://www.societopia.net/Samples/Dy...dControls.aspx
>
> For a clear explanation of the page life cycle:
> http://msdn.microsoft.com/library/de.../viewstate.asp
>
> --
> [note: if this post answers your question, you can mark it as an answer
> using the web-based newsreader functions]
> -----
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Sridhar" wrote:
>
>> Hi,
>>
>> I have created a web page which includes a place holder. I also have
>> a
>> dropdown list in that webpage. when I select one of the choices in
>> that
>> dropdown list, It will load a user control into the place holder.
>> This
>> is
>> done dynamically based on the choice they selected. This user control
>> has
>> a
>> datagrid in it that supports paging. When I click on the next or prev
>> buttons
>> of the datagrid in a user control it should display the next page
>> results.
>> but it is not doing so. I am not knowing how to call the
>> PageIndexChange d
>> event of the user control from the webpage. could anyone show me a
>> code
>> sample to do that? I am using VB.NET for this.
>>
>> Thanks,
>> Sridhar.


Nov 20 '05 #10

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

Similar topics

18
2886
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the originator) and e (event arguments). I know how to get typeof (sender) to determine what form or...
5
1715
by: Russell Smallwood | last post by:
Hello all, Why can't I wire up an event during the "Raise PostBackEvent" stage of a postback? Just in case this is the wrong question, the situation: deep in the bowls of some code-behind loop: ImageButton A is created (with ID "A"). ImageButton A's click event is
15
26512
by: Amit D.Shinde | last post by:
I am adding a new picturebox control at runtime on the form How can i create click event handler for this control Amit Shinde
5
3341
by: Steve | last post by:
I have a datagrid in a WinForm. When the user edits an entry in the datagrid, after he leaves that field, I would like to do some cheking. What event fires when the user does that? I need to make sure that the value he modified does not create a dup value in my DB. Thank you for your help, Steve
2
3833
by: Developer_Software | last post by:
Thanks in advance to anyone who can help :) I've got a placeholder control WITHIN A USER CONTROL that has its contents dynamically added and removed at runtime by a regular .aspx page. At runtime, the placeholder control adds a dropdownlist where I would like it to redirect the user to a different page dependent on the selection they make from the dropdownlist. I've tried writing the delegate and the event handler both in the
3
1558
by: c676228 | last post by:
Hi all, I have an event in user control email to handling email change when user want to change the input for email address. Here it is In email.ascx.vb: Protected Sub UpdateEmail(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtEmail.TextChanged If Session("Email") <> Me.Email Then Session("Email") = TxtEmail.Text 'or me.email End If End Sub
1
4537
by: EricRybarczyk | last post by:
I am starting a rewrite of an existing Classic ASP web site in ASP.NET 2.0. The existing ASP application has several types of users, each with a separate login process (separate login page, separate DB tables, etc). For one of these user types, the current application has an additional input field required for login… they have a username, password, and another “location code” field. Please don’t make me explain or justify this…...
2
1530
by: weboweb | last post by:
Hail the experts!!! I'm creating a web user control which displays a hierarchical tree of items from an xml string passed to the control (from the host page) through an exposed property. This xml gets created in the Page_Load method of the host page Each tree item displayed by the control is a LinkButton object. This LinkButton fires a CommandEventHandler event (when the user
1
108757
Frinavale
by: Frinavale | last post by:
Introduction I've seen many questions asked about how to disable the browser's back button and in the past I've replied with "it's simply not possible". It's not a good idea to disable the back button anyways, if the user ventures away from your page then they wouldn't have this button at their disposal. The main reason people ask how to control or disable the back button is because they have a need to control sensitive (and/or) dynamic web...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
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...
0
9257
jinu1996
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...
0
8099
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 projectplanning, coding, testing, and deploymentwithout 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
6702
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
6011
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();...
1
3228
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
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
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.