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 8123925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:18:45+00:00 2026-06-06T06:18:45+00:00

I’m trying to initialize a usercontrol that contains a gridview as hidden when a

  • 0

I’m trying to initialize a usercontrol that contains a gridview as hidden when a page first loads. When the user clicks a “Search” button on the page then I want to show the gridview that’s within that usercontrol. I’ve tried a bunch of different methods for showing and hiding the user control. I’ve tried placing the usercontrol in a div and then using style=”display: none” to initialize the div as being hidden, and then in the code behind changing the style to ‘block’. I’ve tried using 2 classes with one class having display set to none and the other with display set to block, and then switching between these 2 classes based on user clicking on “Search” button. I’ve tried using a Panel and setting its visibility to true/false, but the panel never shows when I set its visibility to true after the user clicks on the Search button. All methods I’ve tried, except using a panel and its visibility option, give me the following exception:

{InnerText = '((System.Web.UI.HtmlControls.HtmlContainerControl)(divGrid)).InnerText' threw an exception of type 'System.Web.HttpException'}

Here’s the code I’m using that’s causing me this error:

markup:

<div id="divGrid" runat="server">
    <uc1:ContactsGridUserControl ID="ContactsGridUserControl1" runat="server" UpdateMode="Conditional"/>      
</div> 

<asp:Button ID="btnSearch" runat="server" Text="Search" Font-Size="Small" Height="30px" 
                Width="67px" ClientIDMode="Static" onclick="btnSearch_Click"></asp:Button>

code behind:

protected void btnSearch_Click(object sender, EventArgs e)
{
    //string redirect = CommonStrings.editContactPage;
    bool bStatus = false;

    try
    {
        bStatus = validateFields();

        if (bStatus)
        {
            divGrid.Style["display"] = "block";           

        }
        else
        {
            lblError.Text = "Please enter characters for at least one field below";

        }
    }
    catch (Exception ex)
    {
        lblError.Text = "Exception: " + ex.ToString();
    }
}

protected bool validateFields()
{
    try
    {
        if ((txtbxFirstName.Text != null && txtbxFirstName.Text.Length > 0) ||
            (txtbxLastName.Text != null && txtbxLastName.Text.Length > 0) ||
            (txtbxPhoneNum.Text != null && txtbxPhoneNum.Text.Length > 0) ||
            (txtbxCity.Text != null && txtbxCity.Text.Length > 0) ||
            (txtbxZipCode.Text != null && txtbxZipCode.Text.Length > 0) ||
            (txtDate1.Text != null && txtDate1.Text.Length > 0) ||
            (txtDate2.Text != null && txtDate2.Text.Length > 0) ||
            (txtbxCompanyName.Text != null && txtbxCompanyName.Text.Length > 0))
        {
            return true;

        }
        else
        {
            return false;
        }
    }
    catch (Exception ex)
    {
        lblError.Text = "Exception: " + ex.ToString();
        return false;
    }
}

Full Stack Trace: (I right clicked on Call Stack Window within Visual Studio and chose “show external code”. I’m not sure if I did this right to show full stack trace, as opposed to showing what’s on top of the stack by default)

App_Web_gjla55xr.dll!AdvancedSearch.btnSearch_Click(object sender, System.EventArgs e) Line 50 C#
System.Web.dll!System.Web.UI.WebControls.Button.OnClick(System.EventArgs e) + 0x77 bytes
System.Web.dll!System.Web.UI.WebControls.Button.RaisePostBackEvent(string eventArgument) + 0x71 bytes
System.Web.dll!System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(string eventArgument) + 0xb bytes
System.Web.dll!System.Web.UI.Page.RaisePostBackEvent(System.Web.UI.IPostBackEventHandler sourceControl, string eventArgument) + 0xe bytes
System.Web.dll!System.Web.UI.Page.RaisePostBackEvent(System.Collections.Specialized.NameValueCollection postData) + 0x25 bytes
System.Web.dll!System.Web.UI.Page.ProcessRequestMain(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint) + 0x15bc bytes
System.Web.dll!System.Web.UI.Page.ProcessRequest(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint) + 0x8d bytes
System.Web.dll!System.Web.UI.Page.ProcessRequest() + 0x4f bytes
System.Web.dll!System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext context) + 0x16 bytes
System.Web.dll!System.Web.UI.Page.ProcessRequest(System.Web.HttpContext context) + 0x32 bytes
App_Web_gjla55xr.dll!ASP.advancedsearch_aspx.ProcessRequest(System.Web.HttpContext context) + 0x33 bytes C#
System.Web.dll!System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() + 0x65 bytes
System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step, ref bool completedSynchronously) + 0x4c bytes
System.Web.dll!System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(System.Exception error) + 0x13e bytes
System.Web.dll!System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext context, System.AsyncCallback cb, object extraData) + 0xf8 bytes
System.Web.dll!System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest wr) + 0x1a2 bytes
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest wr) + 0x7d bytes
System.Web.dll!System.Web.HttpRuntime.ProcessRequest(System.Web.HttpWorkerRequest wr) + 0x47 bytes
WebDev.WebHost40.dll!Microsoft.VisualStudio.WebHost.Request.Process() + 0x17b bytes
WebDev.WebHost40.dll!Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Microsoft.VisualStudio.WebHost.Connection conn) + 0x6c bytes
[Appdomain Transition]
WebDev.WebHost40.dll!Microsoft.VisualStudio.WebHost.Server.OnSocketAccept(object acceptedSocket) + 0x83 bytes
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state) + 0x2d bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0xb0 bytes
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x5a bytes
mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x147 bytes
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() + 0x2d bytes
[Native to Managed Transition]

Edit: I solved the answer to my problem. I needed to surround the user control with an ajax update panel and have a asyncpostbacktrigger wired to the Search button click event. I also surround the usercontrol with another panel and set that panel’s visibility to true/false from code behind.

updated code:

<asp:UpdatePanel ID="UpdatePanel2" runat="server">
    <ContentTemplate>
        <asp:Panel ID="pnlGrid" Visible="false" runat="server">   
            <uc1:ContactsGridUserControl ID="ContactsGridUserControl1" runat="server" UpdateMode="Conditional"/>
        </asp:Panel>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
    </Triggers>

  • 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-06-06T06:18:46+00:00Added an answer on June 6, 2026 at 6:18 am

    I believe the base class for all ASP.NET WebForms controls is HtmlControl which has a Visible property. Would this work?:

    divGrid.Visible = true; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:

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.