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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:26:20+00:00 2026-06-02T14:26:20+00:00

I have a main web page (Base Page) that makes an ajax call (using

  • 0

I have a main web page (“Base Page”) that makes an ajax call (using jQuery) to the server. The server-side page (“Ajax Page”) is an ASP.NET web form (no MVC in use here). Because (in this case) I’m using a GridView to render data within the ajax response, I have to include the <form runat=”server”> tag.

My complaint is this–when the Base Page receives the AJAX response, it inserts it into the DOM, but because the AJAX response is comprised of HTML markup that includes a <form> tag, this sometimes results in nested html forms, which is bad.

I realize that I can use jquery to only insert a fragment of the response into the Base Page DOM–or that I could use jquery to subsequently strip out the offending <form> tag. But these feel like klunky work-arounds. Is there really no way to prevent the ASP.NET page from serving out its response with a <form> tag? I realize that the form tag is the heart of the ASP.NET webform model, but it sure makes using AJAX in ASP.NET a complicated affair–very much swimming upstream. Surely Microsoft has realized that the postback / server-side model is a thing of the past?

I also realize that Microsoft has some server-side AJAX libraries that probably address this issue–but I’d still like to know if there’s a solution native to ASP.NET webforms.

Any suggestions?

  • 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-02T14:26:21+00:00Added an answer on June 2, 2026 at 2:26 pm

    You can add your GridView to a Web User Control and then render it to a string like this:

    public static string ExecuteToString(this Control control)
    {
        Page page = new Page();
        page.Controls.Add(control);
    
        StringBuilder sb = new StringBuilder();
        using (StringWriter writer = new StringWriter(sb))
        {
            HttpContext.Current.Server.Execute(page, writer, false);
        }
        return sb.ToString();
    }
    

    This means you don’t need to point your ajax request to a page. You can use a web service. Query a specific method and then dynamically load the User Control, render it to a string and return the HTML. Because you put your HTML and code in a User Control you don’t need to worry about stripping out form tags and you can still use all the asp controls as you would on a page.

    I have no idea about the performance costs of using this method but I’ve been using it for a while and it seems fine to me.

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

Sidebar

Related Questions

I have this web application using Spring Web Flow framework. In my main page
I have an ASP.NET application with a <codeSubDirectories> section in web.config. My main project
I have an Asp.Net web page, having the common Asp.Net form. The outer border
I have a simple web page that has 3 tabs in my main content
I am running a web server using VB.net and I have a bunch of
On my web page I have a button that opens a modal jQuery dialog.
I've set up Nginx as my main web server and have two Mochiweb based
In my main Web Page (Viewer.aspx) I have a javascript script tag like this
I have a one-way WCF service, which main purpose is to get Web Page
I want to have a web page that contains 3 parts: A header at

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.