Dynamically Loading User Controls

Discussion in 'ASP .Net' started by Rick Mavrovik, Aug 29, 2007.

  1. Hi,
    I am trying to generate a number of Web User Controls (WUC) based on user
    input.

    This WUC has got 2 drop down controls in it. The WUC works fine when created
    in the usual manner but when I try to create it dynamically a null reference
    exception is thrown when trying to refering any of the drop down.

    UCUserToDeviceInBulk ucTemp = new UCUserToDeviceInBulk();
    ucTemp.Visible = true;
    ucTemp.LoadData(Convert.ToInt32(ddlClient.SelectedItem.Value));
    Inside the LoadDate when I try to use the any of the drop down list.. a null
    reference exception occurs

    public void LoadData(int clientID){
    ddlUser.CssClass = "GAMADdlNormal";
    }

    Does anyone have any clue why this is happening.

    Thanks

    -Rick
     
    Rick Mavrovik, Aug 29, 2007
    #1
    1. Advertising

  2. Hi Rick,
    when do you create your WUCs?

    Regards,
    Ladislav

    "Rick Mavrovik" wrote:

    > Hi,
    > I am trying to generate a number of Web User Controls (WUC) based on user
    > input.
    >
    > This WUC has got 2 drop down controls in it. The WUC works fine when created
    > in the usual manner but when I try to create it dynamically a null reference
    > exception is thrown when trying to refering any of the drop down.
    >
    > UCUserToDeviceInBulk ucTemp = new UCUserToDeviceInBulk();
    > ucTemp.Visible = true;
    > ucTemp.LoadData(Convert.ToInt32(ddlClient.SelectedItem.Value));
    > Inside the LoadDate when I try to use the any of the drop down list.. a null
    > reference exception occurs
    >
    > public void LoadData(int clientID){
    > ddlUser.CssClass = "GAMADdlNormal";
    > }
    >
    > Does anyone have any clue why this is happening.
    >
    > Thanks
    >
    > -Rick
    >
    >
    >
     
    =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?=, Aug 29, 2007
    #2
    1. Advertising

  3. I create the WUCs in button click event.
    The creation of the WUC goes ahead fine. the line below doest not cause the
    error
    UCUserToDeviceInBulk ucTemp = new UCUserToDeviceInBulk();

    -Sami

    "Ladislav Mrnka" <> wrote in message
    news:...
    > Hi Rick,
    > when do you create your WUCs?
    >
    > Regards,
    > Ladislav
    >
    > "Rick Mavrovik" wrote:
    >
    >> Hi,
    >> I am trying to generate a number of Web User Controls (WUC) based on user
    >> input.
    >>
    >> This WUC has got 2 drop down controls in it. The WUC works fine when
    >> created
    >> in the usual manner but when I try to create it dynamically a null
    >> reference
    >> exception is thrown when trying to refering any of the drop down.
    >>
    >> UCUserToDeviceInBulk ucTemp = new UCUserToDeviceInBulk();
    >> ucTemp.Visible = true;
    >> ucTemp.LoadData(Convert.ToInt32(ddlClient.SelectedItem.Value));
    >> Inside the LoadDate when I try to use the any of the drop down list.. a
    >> null
    >> reference exception occurs
    >>
    >> public void LoadData(int clientID){
    >> ddlUser.CssClass = "GAMADdlNormal";
    >> }
    >>
    >> Does anyone have any clue why this is happening.
    >>
    >> Thanks
    >>
    >> -Rick
    >>
    >>
    >>
     
    Rick Mavrovik, Aug 29, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Miller [msft]
    Replies:
    0
    Views:
    615
    Ben Miller [msft]
    Aug 5, 2003
  2. sonic_soul
    Replies:
    0
    Views:
    527
    sonic_soul
    Aug 14, 2003
  3. Nick Stansbury

    loading user controls dynamically

    Nick Stansbury, Jul 19, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    352
    John Saunders
    Jul 19, 2004
  4. =?Utf-8?B?V291dGVy?=

    Dynamically Loaded controls loading other controls

    =?Utf-8?B?V291dGVy?=, Feb 27, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    517
    =?Utf-8?B?V291dGVy?=
    Feb 27, 2006
  5. Bob Rock
    Replies:
    1
    Views:
    689
    Cowboy \(Gregory A. Beamer\)
    Sep 17, 2006
Loading...

Share This Page