Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Catch result

Reply
Thread Tools

Catch result

 
 
shapper
Guest
Posts: n/a
 
      11-09-2006
Hello,

I created a custom control where I have a few textboxes and a button
(MyButton).
When the button is clicked the textboxes data are sent to a database.

In MyButton_Click function I have a variable named Done.
If everything is went well I set this variable to True. Otherwise I set
it to false.

I placed this custom control on my page.

How can I get the value of Done in my page?

Basically, I need, in my page, to take an action according to the value
of Done after the button in the custom control is pressed.

Thanks,
Miguel

 
Reply With Quote
 
 
 
 
Mark Fitzpatrick
Guest
Posts: n/a
 
      11-09-2006
Create a public property that will acess your local private variable

// say this was the intialization of the variable
private bool done = false;

//we would make a property like this.
public bool Done
{
get
{ return done; }
// and if you want to let the form set the done property as well,
include the set accessor
set
{ done = value; }
}


--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006


"shapper" <> wrote in message
news: oups.com...
> Hello,
>
> I created a custom control where I have a few textboxes and a button
> (MyButton).
> When the button is clicked the textboxes data are sent to a database.
>
> In MyButton_Click function I have a variable named Done.
> If everything is went well I set this variable to True. Otherwise I set
> it to false.
>
> I placed this custom control on my page.
>
> How can I get the value of Done in my page?
>
> Basically, I need, in my page, to take an action according to the value
> of Done after the button in the custom control is pressed.
>
> Thanks,
> Miguel
>



 
Reply With Quote
 
 
 
 
shapper
Guest
Posts: n/a
 
      11-09-2006
Hi,

Yes, I know that.

But in my page how can I detect when the button is pressed so I can I
check that value?

I think I am missing something here.

Thanks,
Miguel

Mark Fitzpatrick wrote:
> Create a public property that will acess your local private variable
>
> // say this was the intialization of the variable
> private bool done = false;
>
> //we would make a property like this.
> public bool Done
> {
> get
> { return done; }
> // and if you want to let the form set the done property as well,
> include the set accessor
> set
> { done = value; }
> }
>
>
> --
> Hope this helps,
> Mark Fitzpatrick
> Former Microsoft FrontPage MVP 199?-2006
>
>
> "shapper" <> wrote in message
> news: oups.com...
> > Hello,
> >
> > I created a custom control where I have a few textboxes and a button
> > (MyButton).
> > When the button is clicked the textboxes data are sent to a database.
> >
> > In MyButton_Click function I have a variable named Done.
> > If everything is went well I set this variable to True. Otherwise I set
> > it to false.
> >
> > I placed this custom control on my page.
> >
> > How can I get the value of Done in my page?
> >
> > Basically, I need, in my page, to take an action according to the value
> > of Done after the button in the custom control is pressed.
> >
> > Thanks,
> > Miguel
> >


 
Reply With Quote
 
Andrey Korneyev
Guest
Posts: n/a
 
      11-09-2006
Declare an event, which your control would raise. Handle that event in your
ASPX form.
I hope you know how to create events in C#.

Andrey.

"shapper" <> wrote in message
news: ups.com...
> Hi,
>
> Yes, I know that.
>
> But in my page how can I detect when the button is pressed so I can I
> check that value?
>
> I think I am missing something here.
>
> Thanks,
> Miguel



 
Reply With Quote
 
shapper
Guest
Posts: n/a
 
      11-09-2006
Hi,

I have no idea how to create events in my custom control.
Could you point some links to documentation or maybe an example?

Thanks,
Miguel

Andrey Korneyev wrote:
> Declare an event, which your control would raise. Handle that event in your
> ASPX form.
> I hope you know how to create events in C#.
>
> Andrey.
>
> "shapper" <> wrote in message
> news: ups.com...
> > Hi,
> >
> > Yes, I know that.
> >
> > But in my page how can I detect when the button is pressed so I can I
> > check that value?
> >
> > I think I am missing something here.
> >
> > Thanks,
> > Miguel


 
Reply With Quote
 
Andrey Korneyev
Guest
Posts: n/a
 
      11-09-2006
In order to create event in your control, you should:

1. Create EventArgs class

public class CustomControlButtonPressedEventArgs
{
bool _success;
public CustomControlButtonPressedEventArgs(bool success)
{
_success = success;
}
public bool Success
{
get { return _success; }
}
}

2. Create delegate type (for event handlers)

public delegate void CustomControlButtonPressedEventHandler(object sender,
CustomControlButtonPressedEventArgs e);

3. Create event

public event CustomControlButtonPressedEventHandler
CustomControlButtonPressed;

4. Create OnEvent function for raising the event

protected virtual void
OnCustomControlButtonPressed(CustomControlButtonPr essedEventArgs e)
{
// Check if there are any handlers attached
if (CustomControlButtonPressed != null) CustomControlButtonPressed(this,
e);
}

5. Call OnCustomControlButtonPressed function when your control's button is
actually pressed.

HTH,
Andrey.

"shapper" <> wrote in message
news: oups.com...
> Hi,
>
> I have no idea how to create events in my custom control.
> Could you point some links to documentation or maybe an example?
>
> Thanks,
> Miguel
>
> Andrey Korneyev wrote:
>> Declare an event, which your control would raise. Handle that event in
>> your
>> ASPX form.
>> I hope you know how to create events in C#.
>>
>> Andrey.
>>
>> "shapper" <> wrote in message
>> news: ups.com...
>> > Hi,
>> >
>> > Yes, I know that.
>> >
>> > But in my page how can I detect when the button is pressed so I can I
>> > check that value?
>> >
>> > I think I am missing something here.
>> >
>> > Thanks,
>> > Miguel

>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
catch doesn't catch a thrown exception Marteno Rodia Java 5 08-05-2009 03:30 AM
simulation result is correct but synthesis result is not correct J.Ram VHDL 7 12-03-2008 01:26 PM
catch(...) doesn't catch everything Adam C++ 9 02-02-2006 05:02 PM
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM
why catch (...) can not catch such exception John Black C++ 8 08-20-2004 02:34 PM



Advertisments