When I step through my code, the ASPX Page_Load happens before the Page_Load
in the User Control. This means that the property values are not set to
their defaults yet in the User Control and all the properties are blank. So
my question is, where is the best place to put the code that handles the
form. I was hoping to put it in the Page_Load on the ASPX page. Since the
properties aren't available to the ASPX page at that point, I have only a
few options that I can see.
1) Add all the Insert/Update code to the User Control, which I would rather
not do. I would like to keep the data manipulation out of the User Controls
so that I can use them other places. They are basically formatted forms
with exposed Properties. One problem with the separation idea is that the
Controls where I need to add events need to handled by the file that adds
the Control, unless I'm missing someway of wiring up events in the ASPX file
that happen in the User Control. Haven't seen a way to do that yet.
2) Use Request.Form to get the variables passed in the post. Although I've
found this to be problematic because sometimes the variable is prefixed with
'_ucl' or the User Control's name and a colon and sometimes it's not.
3) Add the manipulation code to and event that happens in the ASPX page.
For a form post I would add an event to the control I'm using for the submit
button.
Anyone care to comment? Give me some new ideas maybe?
Thanks in advance!
Andrea 6 1437
you should implement IPostBackDataHandler, so that your user control will be
updated with postback data before the onload event.
-- bruce (sqlwork.com)
"Andrea Williams" <an*******@hotmail.IHATESpam.com> wrote in message
news:u0**************@TK2MSFTNGP11.phx.gbl... When I step through my code, the ASPX Page_Load happens before the
Page_Load in the User Control. This means that the property values are not set to their defaults yet in the User Control and all the properties are blank.
So my question is, where is the best place to put the code that handles the form. I was hoping to put it in the Page_Load on the ASPX page. Since
the properties aren't available to the ASPX page at that point, I have only a few options that I can see.
1) Add all the Insert/Update code to the User Control, which I would
rather not do. I would like to keep the data manipulation out of the User
Controls so that I can use them other places. They are basically formatted forms with exposed Properties. One problem with the separation idea is that the Controls where I need to add events need to handled by the file that adds the Control, unless I'm missing someway of wiring up events in the ASPX
file that happen in the User Control. Haven't seen a way to do that yet. 2) Use Request.Form to get the variables passed in the post. Although
I've found this to be problematic because sometimes the variable is prefixed
with '_ucl' or the User Control's name and a colon and sometimes it's not. 3) Add the manipulation code to and event that happens in the ASPX page. For a form post I would add an event to the control I'm using for the
submit button.
Anyone care to comment? Give me some new ideas maybe?
Thanks in advance! Andrea
I've looked around on the web sites (that I know about) that offer samples
and found pretty cryptic information on this subject. Interfaces are pretty
new to me and I'm not sure that they have been properly explianed to me. (I
moved from Classic ASP.) Are there any code samples that might help me
understand this a little more? I see the basics but I'm not sure what to do
in the overridden methods.
In the LoadPostData method, for example. Do I need to do something to make
the values be populated in the Controls?
Do I have to add the Render method and render my controls with code, or can
I just leave it in the HTML?
I just need a basic example that take a couple of HTML declared controls and
exposes them so that I can access the values in the ASPX Page_Load method.
All the samples I've seen are for another purpose.
Thanks!
Andrea
"bruce barker" <no***********@safeco.com> wrote in message
news:uv*************@TK2MSFTNGP11.phx.gbl... you should implement IPostBackDataHandler, so that your user control will
be updated with postback data before the onload event.
-- bruce (sqlwork.com)
"Andrea Williams" <an*******@hotmail.IHATESpam.com> wrote in message news:u0**************@TK2MSFTNGP11.phx.gbl... When I step through my code, the ASPX Page_Load happens before the Page_Load in the User Control. This means that the property values are not set to their defaults yet in the User Control and all the properties are blank. So my question is, where is the best place to put the code that handles the form. I was hoping to put it in the Page_Load on the ASPX page. Since the properties aren't available to the ASPX page at that point, I have only
a few options that I can see.
1) Add all the Insert/Update code to the User Control, which I would rather not do. I would like to keep the data manipulation out of the User Controls so that I can use them other places. They are basically formatted forms with exposed Properties. One problem with the separation idea is that
the Controls where I need to add events need to handled by the file that
adds the Control, unless I'm missing someway of wiring up events in the ASPX file that happen in the User Control. Haven't seen a way to do that yet. 2) Use Request.Form to get the variables passed in the post. Although I've found this to be problematic because sometimes the variable is prefixed with '_ucl' or the User Control's name and a colon and sometimes it's not. 3) Add the manipulation code to and event that happens in the ASPX page. For a form post I would add an event to the control I'm using for the submit button.
Anyone care to comment? Give me some new ideas maybe?
Thanks in advance! Andrea
Andrea,
There's a few ways to set properties or call functions on the main page
from a user control. I'm using code like:
Dim myParent As MainReport
'The page is the HTTPHandler
myParent = CType(HttpContext.Current.Handler, MainReport)
myParent.myProperty = "T"
myParent.myFunction()
where MainReport.aspx is the page.
I have one page and I load one of many controls at a time
and this is working well for me.
HTH,
Jim
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Set properties, yes. But if my property for a textbox in the User Control
looks like this:
public string Login
{
get{return txtLogin.Text;}
set{txtLogin.Text = value;}
}
And I try to get a value out of it from the ASPX Page_Load method, the value
is blank. This is b/c by default the Page_Load of the ASPX loads before the
UserControl loads, or at least that's what I'm assuming Since when stepping
through the code I get all the way through Page_Load for the ASPX and then
it pop over to the Page_Load in the User Control, where at that point, I can
see that now the Properties return values.
So if what you propose would fix my problem and allow me to access the
properties from the User Control in the Page_Load method of the ASPX page,
I'm not seeing it. Can you explain a little more?
Thanks!
Andrea
"Jim Corey" <jc****@nospamcharter.net> wrote in message
news:uX*************@TK2MSFTNGP09.phx.gbl... Andrea,
There's a few ways to set properties or call functions on the main page from a user control. I'm using code like:
Dim myParent As MainReport
'The page is the HTTPHandler myParent = CType(HttpContext.Current.Handler, MainReport) myParent.myProperty = "T" myParent.myFunction()
where MainReport.aspx is the page.
I have one page and I load one of many controls at a time and this is working well for me.
HTH, Jim
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
No, my example would not help in the way you describe.
If you were reacting to a button on the user control you would be ok, since
the value would be there by the time the button_click event got fired (
after the page_load events for
the page and user control.
Plus I don't know if you're property is going to work, since there would
have to
be some way to persist 'value' across postbacks.
You may want to check some of the sample apps at www.asp.net / starter kits.
The time tracker app uses user controls and you may see a pattern that fits
what you're trying to do.
Jim
"Andrea Williams" <an*******@hotmail.IHATESpam.com> wrote in message
news:#y**************@TK2MSFTNGP10.phx.gbl... Set properties, yes. But if my property for a textbox in the User Control looks like this:
public string Login { get{return txtLogin.Text;} set{txtLogin.Text = value;} }
And I try to get a value out of it from the ASPX Page_Load method, the
value is blank. This is b/c by default the Page_Load of the ASPX loads before
the UserControl loads, or at least that's what I'm assuming Since when
stepping through the code I get all the way through Page_Load for the ASPX and then it pop over to the Page_Load in the User Control, where at that point, I
can see that now the Properties return values.
So if what you propose would fix my problem and allow me to access the properties from the User Control in the Page_Load method of the ASPX page, I'm not seeing it. Can you explain a little more?
Thanks! Andrea
"Jim Corey" <jc****@nospamcharter.net> wrote in message news:uX*************@TK2MSFTNGP09.phx.gbl... Andrea,
There's a few ways to set properties or call functions on the main page from a user control. I'm using code like:
Dim myParent As MainReport
'The page is the HTTPHandler myParent = CType(HttpContext.Current.Handler, MainReport) myParent.myProperty = "T" myParent.myFunction()
where MainReport.aspx is the page.
I have one page and I load one of many controls at a time and this is working well for me.
HTH, Jim
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
I have, actually, that's why I think that I should be able to do it this
way.
For an example, look at this URL: http://www.dotnetjunkies.com/quickst...s/Pagelet5.src
When you see the source of the User Control, they are exposing the
properties as I would like to.
Later....
I just made a few modification and ran the debugger again... I don't know
why I wasn't seeing the values populated, but I am now. I'm very confused.
Maybe a caching issue the last time I ran it? Guessing...
I could go back to a previous version to see, but I'm so happy that it's
working that I don't want to spend any more time on it. If I run into
again, I'll pull back my old version and see if I can find where the problem
was.
I still would like to react to events from the User Control in my ASPX page
and would like some batter instructions and samples on that subject, should
anyone have something.
Thanks again!
Andrea
"Jim Corey" <jc****@nospam.charter.net> wrote in message
news:10*************@corp.supernews.com... No, my example would not help in the way you describe. If you were reacting to a button on the user control you would be ok,
since the value would be there by the time the button_click event got fired ( after the page_load events for the page and user control.
Plus I don't know if you're property is going to work, since there would have to be some way to persist 'value' across postbacks.
You may want to check some of the sample apps at www.asp.net / starter
kits. The time tracker app uses user controls and you may see a pattern that
fits what you're trying to do.
Jim "Andrea Williams" <an*******@hotmail.IHATESpam.com> wrote in message news:#y**************@TK2MSFTNGP10.phx.gbl... Set properties, yes. But if my property for a textbox in the User
Control looks like this:
public string Login { get{return txtLogin.Text;} set{txtLogin.Text = value;} }
And I try to get a value out of it from the ASPX Page_Load method, the value is blank. This is b/c by default the Page_Load of the ASPX loads before the UserControl loads, or at least that's what I'm assuming Since when stepping through the code I get all the way through Page_Load for the ASPX and
then it pop over to the Page_Load in the User Control, where at that point, I can see that now the Properties return values.
So if what you propose would fix my problem and allow me to access the properties from the User Control in the Page_Load method of the ASPX
page, I'm not seeing it. Can you explain a little more?
Thanks! Andrea
"Jim Corey" <jc****@nospamcharter.net> wrote in message news:uX*************@TK2MSFTNGP09.phx.gbl... Andrea,
There's a few ways to set properties or call functions on the main
page from a user control. I'm using code like:
Dim myParent As MainReport
'The page is the HTTPHandler myParent = CType(HttpContext.Current.Handler, MainReport) myParent.myProperty = "T" myParent.myFunction()
where MainReport.aspx is the page.
I have one page and I load one of many controls at a time and this is working well for me.
HTH, Jim
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lloyd Sheen |
last post by:
Is there any one who has actually done this. I have now scanned more web
articles about this with the realization that not one of them (including
MSDN docs) outlines how to do this. This is...
|
by: Jim Heavey |
last post by:
Hello, I have a user control which I place at the top of each page. I want to have code in this user control which sets the value of a couple of module variables and I was wondering if I create a...
|
by: Reza Nabi |
last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a
placeholder dynamically based on the ctlName querystring passed in the URL.
Webform (LoadCtl.aspx) also passes a...
|
by: Prince Mathew |
last post by:
Hi All,
I have a requirement. I am throwing an exception from my user control I want
to catch this in my container page. Is this possible?
I don't want any event to be raised.
PLEASE...
|
by: campwes |
last post by:
Hey there. I have a user control on an aspx page that displays data
based on a query (handled by another user control also on the page).
I've noticed that the first time I navigate to the page...
|
by: Brian Cesafsky |
last post by:
I am using framework 1.1
I have a user control and a web page.
I want to set up properties on the user control, so I can access the text
boxes on the user control when I am in the code behind...
|
by: Brian Cesafsky |
last post by:
I am using framework 1.1
I have a user control and a web page.
I want to set up properties on the user control, so I can access the text
boxes on the user control when I am in the code behind...
|
by: weboweb |
last post by:
Hello aspnet experts!
I have a design question for the more experienced developers (more than
me at least :-)).
1) I have a page in the application I'm building that displays a web
user...
|
by: Gummy |
last post by:
Hello,
I created a user control that has a ListBox and a RadioButtonList (and other
stuff). The idea is that I put the user control on the ASPX page multiple
times and each user control will...
|
by: =?Utf-8?B?UmljaEI=?= |
last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I
would like to dynamically add panes to the control with a form template added
when the pane is added. I have tried...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |