Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > ASP.NET html-less pages

Reply
Thread Tools

ASP.NET html-less pages

 
 
Epetruk
Guest
Posts: n/a
 
      02-08-2005
Hi,

I'm looking for samples of ASP.NET projects where the programming has been
done almost entirely using codebehind and classes with very little code in
the aspx files themselves.

I would like to be able to write ASP.NET pages where I represented the
elements on the page entirely with classes in codebehind (let's call them
RenderClasses). The idea would be that each of these classes would have a
Render method which would cause the appropriate html to be generated on
screen when it was called so that the visual element that the class instance
represented would be displayed in the browser.

So when the page loaded (in Page_Load), I would instantiate different types
of these RenderClasses, set their various properties and then I would call
their Render methods. Also, if I needed to change the appearance of the page
after user interaction, I would simply change the properties of these
instances in codebehind and then call the Render method. (Something like the
model-view-controller architecture.)

I know that the ASP.NET model has classes that derive from
System.Web.UI.Control that represent many of the common elements we have in
forms. Would these classes do exactly what I want? Would it be possible for
me to have an aspx page which had no html at all, with the html being
generated by the Render methods? And very importantly, does anyone know of
any sample project that has been written using this technique? Are there any
potential pitfalls in terms of server processing?

Thanks in advance,

--
Akin

aknak at aksoto dot idps dot co dot uk



of these classes that would cause appropriate content to be displayed on
the browser. Also, if I needed to change the appearance of the page through
user interaction, I would change the properties of the class instances then
call the Render method


 
Reply With Quote
 
 
 
 
DalePres
Guest
Posts: n/a
 
      02-08-2005
Check out the HtmlTextWriter.AddAttribute(), .AddStyleAttribute(),
..RenderBeginTag() and .RenderEndTag() methods and the HtmlTextWriterTag and
HtmlTextWriterAttribute enumerations on MSDN. They're great for creating
HTML in code.

If you really want to get into the nuts and bolts, check out the
IHttpHandler interface starting at
http://msdn.microsoft.com/library/de...tphandlers.asp.

HTH

DalePres
MCAD, MCDBA, MCSE

"Steve Lutz" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Akin,
>
> If you leave the ASPX page empty (no HTML), you can just use
> Response.Write
> to output HTML.
>
> Custom controls can use HTTPCurrentContext to output also when their
> Rended
> method is invoked.
>
> So you're Page_Load might look like:
>
> .... C# ....
> MyCustomerControl mc1 = new MyCustomControl1();
> mc1.SomeProperty = somevalue;
> mc1.Render();
> ..........
>
> There is also alot of alternatives you could do with this:
> Instead of manually calling the control's Render method, you could add it
> as
> a delegate for your Page's onRender event. I believe this is how it's done
> when you use the standard WebControls.
>
> I have a question on why you would want this? Is this to obscure the
> output?
>
> Steve
>
>
>
>
>
> "Epetruk" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi,
>>
>> I'm looking for samples of ASP.NET projects where the programming has
>> been
>> done almost entirely using codebehind and classes with very little code
>> in
>> the aspx files themselves.
>>
>> I would like to be able to write ASP.NET pages where I represented the
>> elements on the page entirely with classes in codebehind (let's call them
>> RenderClasses). The idea would be that each of these classes would have a
>> Render method which would cause the appropriate html to be generated on
>> screen when it was called so that the visual element that the class

> instance
>> represented would be displayed in the browser.
>>
>> So when the page loaded (in Page_Load), I would instantiate different

> types
>> of these RenderClasses, set their various properties and then I would
>> call
>> their Render methods. Also, if I needed to change the appearance of the

> page
>> after user interaction, I would simply change the properties of these
>> instances in codebehind and then call the Render method. (Something like

> the
>> model-view-controller architecture.)
>>
>> I know that the ASP.NET model has classes that derive from
>> System.Web.UI.Control that represent many of the common elements we have

> in
>> forms. Would these classes do exactly what I want? Would it be possible

> for
>> me to have an aspx page which had no html at all, with the html being
>> generated by the Render methods? And very importantly, does anyone know
>> of
>> any sample project that has been written using this technique? Are there

> any
>> potential pitfalls in terms of server processing?
>>
>> Thanks in advance,
>>
>> --
>> Akin
>>
>> aknak at aksoto dot idps dot co dot uk
>>
>>
>>
>> of these classes that would cause appropriate content to be displayed on
>> the browser. Also, if I needed to change the appearance of the page

> through
>> user interaction, I would change the properties of the class instances

> then
>> call the Render method
>>
>>

>
>



 
Reply With Quote
 
 
 
 
Epetruk
Guest
Posts: n/a
 
      02-08-2005
Steve Lutz wrote:
> Akin,
>
> If you leave the ASPX page empty (no HTML), you can just use
> Response.Write to output HTML.
>
> Custom controls can use HTTPCurrentContext to output also when their
> Rended method is invoked.
>
> So you're Page_Load might look like:
>
> .... C# ....
> MyCustomerControl mc1 = new MyCustomControl1();
> mc1.SomeProperty = somevalue;
> mc1.Render();
> ..........
>
> There is also alot of alternatives you could do with this:
> Instead of manually calling the control's Render method, you could
> add it as a delegate for your Page's onRender event. I believe this
> is how it's done when you use the standard WebControls.
>
> I have a question on why you would want this? Is this to obscure the
> output?


Hi Steve,

Thanks for your answer.

To answer your question about why I would want to do this: well, coming from
a desktop software development background, I guess I'm more comfortable with
a model where the UI is entirely represented in a programming language like
VB or C#.

Cheers,

Akin


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert htm pages to aspx pages moondaddy ASP .Net 5 12-15-2005 08:45 PM
Running aspx pages on 1&1, signed library and master pages Carl Gilbert ASP .Net 1 07-08-2005 06:58 PM
Converting ASP.NET pages directly to PDF pages. Ryan Taylor ASP .Net 3 09-29-2004 08:33 PM
GRRR! Pages submitting with Enter key, combined with .ASCX pages - help! Mike Kingscott ASP .Net 0 12-05-2003 02:56 PM
Four ASP.NET Pages in Frames Vs. One ASP.NET Pages Manish ASP .Net 1 11-17-2003 05:56 PM



Advertisments