Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
AnswerRe: Multi-Threading Pin
Garth J Lancaster15-Aug-13 3:26
professionalGarth J Lancaster15-Aug-13 3:26 
AnswerRe: Multi-Threading Pin
Ravi Bhavnani15-Aug-13 5:02
professionalRavi Bhavnani15-Aug-13 5:02 
GeneralRe: Multi-Threading Pin
bh_15-Aug-13 21:17
bh_15-Aug-13 21:17 
GeneralRe: Multi-Threading Pin
Ravi Bhavnani16-Aug-13 5:36
professionalRavi Bhavnani16-Aug-13 5:36 
GeneralRe: Multi-Threading Pin
bh_16-Aug-13 5:41
bh_16-Aug-13 5:41 
AnswerRe: Multi-Threading Pin
Forbiddenx16-Aug-13 8:13
Forbiddenx16-Aug-13 8:13 
AnswerRe: Multi-Threading Pin
Septimus Hedgehog16-Aug-13 9:38
Septimus Hedgehog16-Aug-13 9:38 
QuestionASP.NET C# Custom Control with Postback. Pin
Forbiddenx14-Aug-13 3:29
Forbiddenx14-Aug-13 3:29 
Hi All,

First time posting here, long time programmer..

So, I have a need for custom controls that I am using to dynamically render a list with call backs..

So, far I had no problem doing simple inherited based controls and hooking their callbacks...
IE CusControl : TextBox...
Then its fairly easy to hook the TextChanged event and add the controls a dynamic list and catch the post backs.

Now, the hard part is when I am no longer inheriting the TextBox base control.. but instead I want to create my own control (combo of many controls) and expose my own events to the page that contains my custom control.

For example..
I have a class, and inside the class I create my own controls.

example of the idea..
C#
public class CusParamTextBox : BaseParam
{
    public TextBox ParamTxtBox;

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        CreateCustomChildControls();
    }

    private void CreateCustomChildControls()
    {
        ParamTxtBox = new TextBox();
        ParamTxtBox.AutoPostBack = true;
        ParamTxtBox.TextChanged += new EventHandler(ParamTxtBox_TextChanged);

        base.Controls.Add(ParamTxtBox);
    }

    public void ParamTxtBox_TextChanged(object sender, EventArgs e)
    {
        TextBox cuscontrol = (TextBox)sender;
        ParamTxtBox.Text = "fired!";
        //this works.. so maybe it could be used to fire the local update event that then
        //could be exposed outside of the class.
    }

 //need to add some sort of event code for update event to expose outside of local class...
 //example ExposedUpdate()
}


Ok, so now I want to expose another event ExposedUpdate() outside of this class..
kind of like a universal update event that I want to be able to hook to the page that loads this control.

So.. inside my ASP.NET Page that contains the custom control I want to hook my own event somehow.. something like this...

C#
//example of adding the event..

// protected override void OnInit(EventArgs e)
CusParamTextBox tmpctrlx = new CusParamTextBox();
tmpctrlx.ExposedUpdate() += new EventHandler(this.Update);

    protected void UpdateText(object sender, EventArgs e)
    {
        CusParamTextBox cuscontrol = (CusParamTextBox)sender;
        DosomethingOnPage(cuscontrol.name,cusontrol.value);
        upMain.Update();
    }


The idea would be, that the local event fires off on TextChanged then fires off the other ExposedEvent that would then be hooked into the main page to fire off more code on the main page.

Any idea or am i off the rocker and there is a better way to do this ?
=)

AnswerRe: ASP.NET C# Custom Control with Postback. Pin
OriginalGriff14-Aug-13 3:41
mveOriginalGriff14-Aug-13 3:41 
GeneralRe: ASP.NET C# Custom Control with Postback. Pin
Richard MacCutchan14-Aug-13 3:43
mveRichard MacCutchan14-Aug-13 3:43 
SuggestionRe: ASP.NET C# Custom Control with Postback. Pin
Richard MacCutchan14-Aug-13 3:42
mveRichard MacCutchan14-Aug-13 3:42 
GeneralRe: ASP.NET C# Custom Control with Postback. Pin
Forbiddenx14-Aug-13 3:51
Forbiddenx14-Aug-13 3:51 
GeneralRe: ASP.NET C# Custom Control with Postback. Pin
Richard MacCutchan14-Aug-13 4:29
mveRichard MacCutchan14-Aug-13 4:29 
GeneralRe: ASP.NET C# Custom Control with Postback. Pin
Chris Maunder14-Aug-13 4:40
cofounderChris Maunder14-Aug-13 4:40 
AnswerRe: ASP.NET C# Custom Control with Postback. Pin
Richard Deeming14-Aug-13 3:47
mveRichard Deeming14-Aug-13 3:47 
GeneralRe: ASP.NET C# Custom Control with Postback. Pin
Forbiddenx14-Aug-13 3:57
Forbiddenx14-Aug-13 3:57 
AnswerRe: ASP.NET C# Custom Control with Postback. Pin
Richard Deeming14-Aug-13 4:01
mveRichard Deeming14-Aug-13 4:01 
GeneralRe: ASP.NET C# Custom Control with Postback. Pin
Forbiddenx14-Aug-13 5:18
Forbiddenx14-Aug-13 5:18 
GeneralRe: ASP.NET C# Custom Control with Postback. Pin
Forbiddenx14-Aug-13 7:35
Forbiddenx14-Aug-13 7:35 
GeneralRe: ASP.NET C# Custom Control with Postback. Pin
Richard Deeming14-Aug-13 7:55
mveRichard Deeming14-Aug-13 7:55 
GeneralRe: ASP.NET C# Custom Control with Postback. Pin
Forbiddenx14-Aug-13 8:03
Forbiddenx14-Aug-13 8:03 
GeneralRe: ASP.NET C# Custom Control with Postback. Pin
Richard Deeming14-Aug-13 8:14
mveRichard Deeming14-Aug-13 8:14 
GeneralRe: ASP.NET C# Custom Control with Postback. Pin
Forbiddenx16-Aug-13 7:59
Forbiddenx16-Aug-13 7:59 
QuestionASP.NET C# Custom Control with Postback. Pin
Forbiddenx14-Aug-13 3:04
Forbiddenx14-Aug-13 3:04 
AnswerRe: ASP.NET C# Custom Control with Postback. Pin
Pete O'Hanlon14-Aug-13 3:12
mvePete O'Hanlon14-Aug-13 3:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.