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

  • SEARCH
  • Home
  • 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 6818209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:09:01+00:00 2026-05-26T21:09:01+00:00

I have a ModalPopupExtender(mpe) which will show when a asp:button is clicked. The button

  • 0

I have a ModalPopupExtender(mpe) which will show when a asp:button is clicked. The button calls a javascript function which then calls a webmethod. The webmethod is in the code behind of the page.

The webmethod passes a string variable to another method in the code behind. which determines what the mpe does. The idea behind this logic is that when you click the button I want to enable certain parts of the mpe and disable other parts. This is because the mpe has several functionalities.

Aspx Button and UserControl

 <uc2:IMG ID="IMG1" runat="server" />
 <asp:Button ID="btnAddNewImg" runat="server" Text="Add New Image" onclientclick="ShowImgPopupScreen()"  />

Javascript function

  <script type="text/javascript">
     function ShowImgPopupScreen() {
         // call server side method
         PageMethods.AddNewImg();
     }   
</script>

ASPX.CS code

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static void AddNewImg()
    {
        string option = "add";
        image_loader_cms cms = new image_loader_cms();
        cms.SetButtons(option);

    }

    protected void SetButtons(string add)
    {
        if (add == "add")
        {
            IMG1.Add = true;


        }
        else
        {
            IMG1.Edit = true;

        }
    }

ASCX.CS

public bool Add
    {
        get
        {
            return btnAdd.Enabled;
        }
        set
        {
            btnAdd.Enabled = value;
        }
    }


    public bool Edit
    {
        get
        {
            return btnUpdate.Enabled;
        }
        set
        {
            btnUpdate.Enabled = value;
        }
    }

The code steps into IMG1.Add = true; when using breakpoints but after that line of code I get this error message.

Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'AddNewImg' failed with the following error:

 System.NullReferenceException-- Object reference not set to an instance of an object.

This problem has me scratching my head.

  • 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-26T21:09:02+00:00Added an answer on May 26, 2026 at 9:09 pm

    You are creating a new usercontrol, however it wont create its child controls or be in anyway usable until it is added to the control tree, hence your image and buttons are never created.

    Since you are in static page method, i dont think this is going to work.

    What are you actually trying to do with the user control from the page moethod ?

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

Sidebar

Related Questions

I've got a page where I have a ModalPopUpExtender which I want to show
I have this modalPopupExtender, I want it to show a CheckBoxList with some data.
I have a gridview inside a ModalPopUpExtender, the grid view have the button add
I have a ajax asp.net modalpopupextender, I wont when I desplay popup, the popup
I tried using this example: http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/modalpopup/modalpopup.aspx <ajaxToolkit:ModalPopupExtender ID=MPE runat=server TargetControlID=LinkButton1 </ajaxToolkit:ModalPopupExtender> And try using
I have a ModalPopupExtender control and a panel which contains a iframe. The ModalPopupExtender's
right now I have a huge Solution in which we use javascript alerts via
I have a page which loads children pages by using jQuery's .load function... My
I am currently working on a ModalPopupExtender in ASP.net with C#. I have the
I am currently developing an ASP.net c# application. I have a grid view which

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.