Saturday 15 February 2014

c# - Including a Handler Response inside a Web Form -


I am generating HTML in page load method in more than 1 page.

All those Generated HTML are the same in all pages.

I found that it is a pain to keep the same code in every page, because once I have to change something, I have to change them in all the pages.

P> Example:

I have div in each page:

& lt; Div id = "question" runat = "server" & gt;

In each page's page load method, I generate the same HTML.

Question.Internet HTML = "& lt; span & gt; ... etc ... ";

So I decided to create a page creating that content, then load it, the page inside the divas of the other pages means, if I ever need to change, then only I I will change this page.

I have created a handler, questions.ashx . This handler generates that HTML and sends a response.

To include it now, I know that I can use the JQUERY .load () function, I want to generate from server side.

Whatever I have tried:

Question. Inner HTML = Load Control ("~ / Handler / Question.Shex") .ostring ();

But I got this error:

type 'question' system. Web. UI. User control '.

"Load control" is for "user control", not a HTTP handler.

You might be better off creating a user control, which is a .ascx file that can contain HTML, ASPX control and rear code, and can be referenced by any ASPX page.

More information here:



No comments:

Post a Comment