CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2007
    Location
    South Africa
    Posts
    263

    How to Refresh the UserControl not the Whole Page In ASP.net

    Good Morning

    I have the Following User Control in the Pic "UserControl_Design_Mode.JPG" and i have the Following code to enable Partial Rendering

    UserControl_Design_Mode.JPg


    Code:
        /*Enabling Partial */
    
        [DefaultValueAttribute(true)]
    
        [CategoryAttribute("Behavior")]
        
        public bool EnablePartialRendering { get; set; }

    Am exposing the Properties of a usercontrol like like this


    Code:
        public UpdatePanelUpdateMode UpdateMode
        {
    
            get
            {
                return this.UpdatePanel1.UpdateMode;
            }
            set
            {
                this.UpdatePanel1.UpdateMode = value;
            }
    
    
        }

    And there are of them


    and i went to the Hosting page we have a pic




    for Example, in the Button Remove i have Finally something like this


    Code:
       Response.Redirect("SubjectStaff.aspx", false); //Refresh the Page again
    I was Forcing a Postback and the Whole Page flickers, i want to Refresh only the UserControl.

    i tried the Following instead of the above statement



    Here am trying to call the name of the usercontrol first and then the Properties it exposes, but i only get the load and load1 event , it seems every is hiden now since i have taken the Control inside the Update Paanel in the User Control.


    Can you Help me in that Regard

    Thanks
    Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."

  2. #2
    Join Date
    Sep 2009
    Posts
    10

    Re: How to Refresh the UserControl not the Whole Page In ASP.net

    As far as I know there is no way to reload a particular part of any page without using some type of independent HTTP request such as Ajax or a Web Service. If you post back it will always reload the entire page because that is what a postback is. You are sending the entire form back to the service for some processing before the entire form is to be rendered again.

    You could use Ajax to re-render a particular component of the page but for what you are describing I dont think that it is a good solution either. Is there any reason why you can't use client-side javascript to make the changes to your page while it's still on the client's machine?

    Using a javascript type approach you would just render the html for the full component. If EnablePartialRendering is set then it should just set the style attribute of the html elements you want not to be visible to style="display:none;". This will make sure that they are not visible in partial mode. Basically you would render some javascript that would look something like this:

    function PartialMode()
    {
    //set style properties for elements to be hidden
    document.getElementById("ELEMENT1").style.display="none";
    document.getElementById("ELEMENT2").style.display="none";
    document.getElementById("ELEMENT3").style.display="none";
    document.getElementById("ELEMENT4").style.display="none";
    }
    function FullMode()
    {
    //set style properties for elements to be shown
    document.getElementById("ELEMENT1").style.display="";
    document.getElementById("ELEMENT2").style.display="";
    document.getElementById("ELEMENT3").style.display="";
    document.getElementById("ELEMENT4").style.display="";
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured