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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:54:27+00:00 2026-05-30T22:54:27+00:00

I have an ASP.NET C# website and I am attempting to retrieve the inner

  • 0

I have an ASP.NET C# website and I am attempting to retrieve the inner html from a HTML in my page when a button is clicked.

My Problem: I use the function FindControl() but it returns null when it should find the element. Why is this happening, what am I doing wrong?

My HTML page:

<%@ Page Title="test" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="test.aspx.cs" Inherits="test" %>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="ActualContent">
    <div class="regMainContainer mainContainer container">
            <!-- Attempting to get the below div -->
            <!-- Knowtice it does not have runat="server", 
                 I would prefer not to do that if I dont need to -->
            <div id="courseDiv" class="courseContainer">
            </div>
    </div>
</asp:content>

My Code that executes when a button is clicked(inside test.aspx.cs file:

HtmlGenericControl d = (HtmlGenericControl)FindControl("courseDiv");
  • 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-30T22:54:28+00:00Added an answer on May 30, 2026 at 10:54 pm

    FindControl can only find controls that has runat=”server” attributes. The good news is that you can easily change you div to a panel, and add data that way.

    the bad news is that this still won’t let you access the innerhtml of the div, .net sees it as just a container for other controls.

    The best way to do this would be some form of ajax, since your client side script would be able to read that contents and pass it to a server side method

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

Sidebar

Related Questions

I have an asp.net website with a master-page, can I use the iframe so
I have a ASP.NET website. It's got a login page where I use built-in
I have a asp.net website in my local IIS and one of a page
I have an ASP.Net website which has a remember me feature for Login page.
I have an ASP.net website running under IIS6. In one .aspx page the user
I have website that is ASP.NET with Forms Authentication, clicking the logout button does
I have a asp.net website, which use MVC 1.0 framework, but I found sometimes
I have an ASP.NET website and from one of the web pages I need
I have an asp.net website which contains a Thread that fetches some data from
i have a weird problem ! i have ASP.NET website and i have a

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.