Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 933087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:46:28+00:00 2026-05-15T20:46:28+00:00

I have an app with 24 different Forms. They have some security options based

  • 0

I have an app with 24 different Forms. They have some security options based on which the 5 different buttons Submit, Approve, 2nd Approve, 3rd Approve, Reject etc get enabled disabled.

Now I designed a MainForm that has all the buttons and the security code for them. I have created eachform as a usercontrol and load them dynamically based on which form the user wants. My loading works perfectly fine. I load the control and Add it to the place holder in the Page load event of the main page.

Now when the user selects the Submit button I want to call the Save method inside the usercontrol of the Form as each form will have a separate Save. So when I try this code snippet I get the Null reference error. Do let me know how to resolve it.

Private UCDynamic As UserControl

Then on Page Load event I use this code

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If not Me.IsPostBack
            UCDynamic = LoadControl("Controls/BkCode.ascx")
            Me.PlaceHolderForm.Controls.Add(UCDynamic)
End if

Then on the ButtonClick Event for Submit I do this

 Protected Sub Save_OnClick(ByVal sender As Object, ByVal e As EventArgs)
    Save()
End Sub

Sub Save()
    CType(Me.UCDynamic, controls_BkCode).Save()
End Sub

Thats where I get the cast Null reference error. So is it that after post back the control no longer exist on the page. Any ideas will be greatly appreciated.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:46:29+00:00Added an answer on May 15, 2026 at 8:46 pm

    Hi Tim Thanks for your help. But Findcontrol does not work for the placeholder. Though I have the viewstate enabled for the placeholder yet it does not hold the control after post backs.

    Finally resolved this issue by moving my LoadControl code out of If not is postback. So I load the control every time and the code inside the control takes care of the logic of post backs and the viewsataes for the control.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a windows forms app where I have split different functionality into several
I have an app which has different app identifier for iphone and ipad and
I have an UITabBar based iPhone app with 4 different UIWebViews under every tab.
I have an iOS app which gets some JSON from a server (in the
I have an app that has different names for different languages. How do I
I have an app with several different tabs. The first of these tabs should
I have an app that presents Table View of different files. I have it
So I have an app with a 2 different models, Comments and Replies, each
currently I have an app that creates all sorts of different requests to Facebook
I'd like my app to have different functionality depending on whether it launched while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.