Ask a Question related to ASP.NET General, Design and Development.
-
John #1
Urgent : Unsure of when to call a function within a user control
Hi all,
This really is quite an urgent matter.
I have a page with multiple, dynamically-loaded user controls and when a
user clicks on a button, the whole form is submitted. Now at this stage I
know I need to call a function that will save data but I'm not sure exactly
when to call this function.
I've tried two ways and both seem to have 'gotcha's':
1. In the Page_Load event of the PAGE, I call LoadControl to load the user
control (I need to do this to restore viewstate)
2. Immediately after the LoadControl call, I call myusercontrol.Save() but
the viewstate has not been restored since the Page_Load event of the user
control hasn't fired.
so I then tried :
1. In the Page_Load event of the PAGE, I call LoadControl to load the user
control (I need to do this to restore viewstate)
2. Immediately after the LoadControl call, I populate a session variable to
use in the Page_Load event of my user control.
3. The Page_Load event of my user control fires (because the Page_Load event
of my PAGE ended normally)
4. Right at the end of the Page_Load event of my user control, I call the
Save method contained within but during the save, I don't have access to the
controls on my form (agaion, a viewstate problem).
Exactly where am I supposed to call the public Save method of my user
control?
I hope I've explained clearly as this needs a good, proper solution asap.
Thankyou!
Regards
John.
John Guest
-
Urgent User Control
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? ... -
URGENT! Error in web service function call - web services behavior
I am getting the following message when trying to call a web service in javascript(from an ASP.NET application) using web services behavior: ... -
Internet Explorer Window Form User Control - Embed - Urgent
Hi, This is URGENT, THANKS! Without getting into the "why", here's what I'd like to do, followed by where I am: 1. I would like to embed an... -
Urgent Question in Custom Paging User Control
how is that an asp.net issue? isn't this a 3rd party control? what is the point of posting this message all over the net? -- Regards, Alvin... -
William F. Robertson, Jr. #2
Re: Urgent : Unsure of when to call a function within a user control
Why don't you wire the Save method of your user control to the click
function that is submitting the form? That way, after you LoadControl, the
event will be wired and when the click event is sent, it will run the Save
method?
bill
"John" <a@b.com> wrote in message
news:eeRLjuuSDHA.1552@TK2MSFTNGP10.phx.gbl...exactly> Hi all,
>
> This really is quite an urgent matter.
>
> I have a page with multiple, dynamically-loaded user controls and when a
> user clicks on a button, the whole form is submitted. Now at this stage I
> know I need to call a function that will save data but I'm not sureto> when to call this function.
>
> I've tried two ways and both seem to have 'gotcha's':
>
> 1. In the Page_Load event of the PAGE, I call LoadControl to load the user
> control (I need to do this to restore viewstate)
> 2. Immediately after the LoadControl call, I call myusercontrol.Save() but
> the viewstate has not been restored since the Page_Load event of the user
> control hasn't fired.
>
> so I then tried :
>
> 1. In the Page_Load event of the PAGE, I call LoadControl to load the user
> control (I need to do this to restore viewstate)
> 2. Immediately after the LoadControl call, I populate a session variableevent> use in the Page_Load event of my user control.
> 3. The Page_Load event of my user control fires (because the Page_Loadthe> of my PAGE ended normally)
> 4. Right at the end of the Page_Load event of my user control, I call the
> Save method contained within but during the save, I don't have access to> controls on my form (agaion, a viewstate problem).
>
> Exactly where am I supposed to call the public Save method of my user
> control?
>
> I hope I've explained clearly as this needs a good, proper solution asap.
> Thankyou!
>
> Regards
> John.
>
>
William F. Robertson, Jr. Guest
-
S. Justin Gengo #3
Re: Urgent : Unsure of when to call a function within a user control
John,
I'm also using dynamically loaded user controls and I also restore the
controls to access view state properties when the form is submitted.
I then call my save, delete, etc. functions using the OnBubbleEvent.
Any button in a user control automatically "bubbles" it's click event (and
the others too...) up to the page the control is hosted on.
Here's a small sample to get you going...
Protected Overrides Function OnBubbleEvent(ByVal source As Object, ByVal
args As System.EventArgs) As Boolean
'---Get the object that triggered the event
Select Case (source.GetType.ToString)
Case "System.Web.UI.WebControls.Button"
'---Get the button
Dim Button As Button = CType(source,
System.Web.UI.WebControls.Button)
'---Find out which button was clicked
Select Case Button.Id
Case "Submit"
'---Call the submit sub
Call MySubmitSub()
Case "Delete"
'---Call the delete sub
Call MyDeleteSub()
End Select
Case "System.Web.UI.WebControls.ImageButton"
'---Find out which imagebutton was clicked
End Select
End Function
I hope this helps.
Justin
"John" <a@b.com> wrote in message
news:eeRLjuuSDHA.1552@TK2MSFTNGP10.phx.gbl...exactly> Hi all,
>
> This really is quite an urgent matter.
>
> I have a page with multiple, dynamically-loaded user controls and when a
> user clicks on a button, the whole form is submitted. Now at this stage I
> know I need to call a function that will save data but I'm not sureto> when to call this function.
>
> I've tried two ways and both seem to have 'gotcha's':
>
> 1. In the Page_Load event of the PAGE, I call LoadControl to load the user
> control (I need to do this to restore viewstate)
> 2. Immediately after the LoadControl call, I call myusercontrol.Save() but
> the viewstate has not been restored since the Page_Load event of the user
> control hasn't fired.
>
> so I then tried :
>
> 1. In the Page_Load event of the PAGE, I call LoadControl to load the user
> control (I need to do this to restore viewstate)
> 2. Immediately after the LoadControl call, I populate a session variableevent> use in the Page_Load event of my user control.
> 3. The Page_Load event of my user control fires (because the Page_Loadthe> of my PAGE ended normally)
> 4. Right at the end of the Page_Load event of my user control, I call the
> Save method contained within but during the save, I don't have access to> controls on my form (agaion, a viewstate problem).
>
> Exactly where am I supposed to call the public Save method of my user
> control?
>
> I hope I've explained clearly as this needs a good, proper solution asap.
> Thankyou!
>
> Regards
> John.
>
>
S. Justin Gengo Guest
-
John #4
Re: Urgent : Unsure of when to call a function within a user control
O.K. thanks. I hear what you're saying but the form is submitted via a
javascript. I display a confirm box and if the user clicks OK, I use the
form.submit() method. What do I do then?
"S. Justin Gengo" <gengoj@krause.com> wrote in message
news:vh8bimitne1r85@corp.supernews.com...I> John,
>
> I'm also using dynamically loaded user controls and I also restore the
> controls to access view state properties when the form is submitted.
>
> I then call my save, delete, etc. functions using the OnBubbleEvent.
>
> Any button in a user control automatically "bubbles" it's click event (and
> the others too...) up to the page the control is hosted on.
>
> Here's a small sample to get you going...
>
> Protected Overrides Function OnBubbleEvent(ByVal source As Object, ByVal
> args As System.EventArgs) As Boolean
> '---Get the object that triggered the event
> Select Case (source.GetType.ToString)
> Case "System.Web.UI.WebControls.Button"
> '---Get the button
> Dim Button As Button = CType(source,
> System.Web.UI.WebControls.Button)
>
> '---Find out which button was clicked
> Select Case Button.Id
> Case "Submit"
> '---Call the submit sub
> Call MySubmitSub()
>
> Case "Delete"
> '---Call the delete sub
> Call MyDeleteSub()
>
> End Select
>
> Case "System.Web.UI.WebControls.ImageButton"
> '---Find out which imagebutton was clicked
>
> End Select
> End Function
>
> I hope this helps.
>
> Justin
>
>
>
> "John" <a@b.com> wrote in message
> news:eeRLjuuSDHA.1552@TK2MSFTNGP10.phx.gbl...> > Hi all,
> >
> > This really is quite an urgent matter.
> >
> > I have a page with multiple, dynamically-loaded user controls and when a
> > user clicks on a button, the whole form is submitted. Now at this stageuser> exactly> > know I need to call a function that will save data but I'm not sure> > when to call this function.
> >
> > I've tried two ways and both seem to have 'gotcha's':
> >
> > 1. In the Page_Load event of the PAGE, I call LoadControl to load thebut> > control (I need to do this to restore viewstate)
> > 2. Immediately after the LoadControl call, I call myusercontrol.Save()user> > the viewstate has not been restored since the Page_Load event of theuser> > control hasn't fired.
> >
> > so I then tried :
> >
> > 1. In the Page_Load event of the PAGE, I call LoadControl to load thethe> to> > control (I need to do this to restore viewstate)
> > 2. Immediately after the LoadControl call, I populate a session variable> event> > use in the Page_Load event of my user control.
> > 3. The Page_Load event of my user control fires (because the Page_Load> > of my PAGE ended normally)
> > 4. Right at the end of the Page_Load event of my user control, I callasap.> the> > Save method contained within but during the save, I don't have access to> > controls on my form (agaion, a viewstate problem).
> >
> > Exactly where am I supposed to call the public Save method of my user
> > control?
> >
> > I hope I've explained clearly as this needs a good, proper solution>> > Thankyou!
> >
> > Regards
> > John.
> >
> >
>
John Guest
-
S. Justin Gengo #5
Re: Urgent : Unsure of when to call a function within a user control
Why are you using form.submit()?
Instead why don't you attach the javascript confirm to the regular submit
button?
Button.Attributes.Add("onclick", "javascript:if (!confirm('Submit?') return
false;")
This way you would be able to use the submit button's onclick event.
--
S. Justin Gengo, MCP
Web Developer / Programmer
Free Code Library At:
[url]www.aboutfortunate.com[/url]
"Out of chaos comes order."
Nietzche
"John" <a@b.com> wrote in message
news:Orr1GK7SDHA.1912@TK2MSFTNGP12.phx.gbl...(and> O.K. thanks. I hear what you're saying but the form is submitted via a
> javascript. I display a confirm box and if the user clicks OK, I use the
> form.submit() method. What do I do then?
>
>
> "S. Justin Gengo" <gengoj@krause.com> wrote in message
> news:vh8bimitne1r85@corp.supernews.com...> > John,
> >
> > I'm also using dynamically loaded user controls and I also restore the
> > controls to access view state properties when the form is submitted.
> >
> > I then call my save, delete, etc. functions using the OnBubbleEvent.
> >
> > Any button in a user control automatically "bubbles" it's click eventa> > the others too...) up to the page the control is hosted on.
> >
> > Here's a small sample to get you going...
> >
> > Protected Overrides Function OnBubbleEvent(ByVal source As Object, ByVal
> > args As System.EventArgs) As Boolean
> > '---Get the object that triggered the event
> > Select Case (source.GetType.ToString)
> > Case "System.Web.UI.WebControls.Button"
> > '---Get the button
> > Dim Button As Button = CType(source,
> > System.Web.UI.WebControls.Button)
> >
> > '---Find out which button was clicked
> > Select Case Button.Id
> > Case "Submit"
> > '---Call the submit sub
> > Call MySubmitSub()
> >
> > Case "Delete"
> > '---Call the delete sub
> > Call MyDeleteSub()
> >
> > End Select
> >
> > Case "System.Web.UI.WebControls.ImageButton"
> > '---Find out which imagebutton was clicked
> >
> > End Select
> > End Function
> >
> > I hope this helps.
> >
> > Justin
> >
> >
> >
> > "John" <a@b.com> wrote in message
> > news:eeRLjuuSDHA.1552@TK2MSFTNGP10.phx.gbl...> > > Hi all,
> > >
> > > This really is quite an urgent matter.
> > >
> > > I have a page with multiple, dynamically-loaded user controls and whenstage> > > user clicks on a button, the whole form is submitted. Now at thisvariable> I> user> > exactly> > > know I need to call a function that will save data but I'm not sure> > > when to call this function.
> > >
> > > I've tried two ways and both seem to have 'gotcha's':
> > >
> > > 1. In the Page_Load event of the PAGE, I call LoadControl to load the> but> > > control (I need to do this to restore viewstate)
> > > 2. Immediately after the LoadControl call, I call myusercontrol.Save()> user> > > the viewstate has not been restored since the Page_Load event of the> user> > > control hasn't fired.
> > >
> > > so I then tried :
> > >
> > > 1. In the Page_Load event of the PAGE, I call LoadControl to load the> > > control (I need to do this to restore viewstate)
> > > 2. Immediately after the LoadControl call, I populate a sessionto> the> > to> > event> > > use in the Page_Load event of my user control.
> > > 3. The Page_Load event of my user control fires (because the Page_Load> > > of my PAGE ended normally)
> > > 4. Right at the end of the Page_Load event of my user control, I call> > > Save method contained within but during the save, I don't have access> asap.> > the> > > controls on my form (agaion, a viewstate problem).
> > >
> > > Exactly where am I supposed to call the public Save method of my user
> > > control?
> > >
> > > I hope I've explained clearly as this needs a good, proper solution>> >> > > Thankyou!
> > >
> > > Regards
> > > John.
> > >
> > >
> >
>
S. Justin Gengo Guest



Reply With Quote

