473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Light ASP.Net Page

Hi,

Would like to know what is the best way of creating an ASP.Net web page that
return just a line of "Text".

This ASP.Net will not required any HTML tag, or Post Back Features.

So we created below in Code Behind:

protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
Response.Clear();
Response.ContentType = "text/plain";

// Some Business Logic

Response.Write(sometext)
}

Is this the best way? The return result "sometext" will be used by
javascript (Ajax). But we still have this in our Form Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs"
Inherits="CUST_Test._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div></div>
</form>
</body>
</html>

Shall i remove all above from the Form Code?

Instead of protected override void Render(HtmlTextWriter writer), can we
just do something like this (probably in the Form Code):

<%
Response.Clear();
Response.ContentType = "text/plain";

// Some Business Logic

Response.Write(sometext)
%>

and then remove all Code Behind and everything, will that improve
performance?

Really appreciate if you can help. Millions Thanks!

Jun 27 '08 #1
3 1280
You could just remove everything and place a Literal control on the page. A
literal doesn't get decorated with extra <spanelements like a Label does.
Your way also works but in either case you'll need to do things like turn
off the session state to ensure it doesn't try to write a viewstate as well.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression

"Thalia Mei" <th*******@gmail.comwrote in message
news:4B**********************************@microsof t.com...
Hi,

Would like to know what is the best way of creating an ASP.Net web page
that return just a line of "Text".

This ASP.Net will not required any HTML tag, or Post Back Features.

So we created below in Code Behind:

protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
Response.Clear();
Response.ContentType = "text/plain";

// Some Business Logic

Response.Write(sometext)
}

Is this the best way? The return result "sometext" will be used by
javascript (Ajax). But we still have this in our Form Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs"
Inherits="CUST_Test._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div></div>
</form>
</body>
</html>

Shall i remove all above from the Form Code?

Instead of protected override void Render(HtmlTextWriter writer), can we
just do something like this (probably in the Form Code):

<%
Response.Clear();
Response.ContentType = "text/plain";

// Some Business Logic

Response.Write(sometext)
%>

and then remove all Code Behind and everything, will that improve
performance?

Really appreciate if you can help. Millions Thanks!
Jun 27 '08 #2
You have a couple of questions, so let's examine them

The lightest you can go is to just spit out the text. Response.Write()
works, as does using a Literal (Mark's suggestion). If you do this, you
should remove all HTML tags, as they will be written if they are on the
page.

Removing CodeBehind? WIll not improve performance. Will make it, depending
on publish mode, so you can alter this single page without updating the
entire site. If that is not a desire, then you really gain nothing by
removing CodeBehind, as you can completely clear out the page and use
CodeBehind only to do what you are trying to do.

One question I have is why you are using a page to deliver text to an AJAX
page? There are so many better ways to accomplish this, including web
services.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
"Thalia Mei" <th*******@gmail.comwrote in message
news:4B**********************************@microsof t.com...
Hi,

Would like to know what is the best way of creating an ASP.Net web page
that return just a line of "Text".

This ASP.Net will not required any HTML tag, or Post Back Features.

So we created below in Code Behind:

protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
Response.Clear();
Response.ContentType = "text/plain";

// Some Business Logic

Response.Write(sometext)
}

Is this the best way? The return result "sometext" will be used by
javascript (Ajax). But we still have this in our Form Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs"
Inherits="CUST_Test._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div></div>
</form>
</body>
</html>

Shall i remove all above from the Form Code?

Instead of protected override void Render(HtmlTextWriter writer), can we
just do something like this (probably in the Form Code):

<%
Response.Clear();
Response.ContentType = "text/plain";

// Some Business Logic

Response.Write(sometext)
%>

and then remove all Code Behind and everything, will that improve
performance?

Really appreciate if you can help. Millions Thanks!

Jun 27 '08 #3
Hi,

Thanks everyone for advice.

The reason we are not using web services is because we try to minimize the
size of the return message, as web services will include extra tags.

The message we return is just one liner that retrieve from a stored
procedure.

I am not sure whether web services is advisable?

Thanks


"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:Ov**************@TK2MSFTNGP04.phx.gbl...
You have a couple of questions, so let's examine them

The lightest you can go is to just spit out the text. Response.Write()
works, as does using a Literal (Mark's suggestion). If you do this, you
should remove all HTML tags, as they will be written if they are on the
page.

Removing CodeBehind? WIll not improve performance. Will make it, depending
on publish mode, so you can alter this single page without updating the
entire site. If that is not a desire, then you really gain nothing by
removing CodeBehind, as you can completely clear out the page and use
CodeBehind only to do what you are trying to do.

One question I have is why you are using a page to deliver text to an AJAX
page? There are so many better ways to accomplish this, including web
services.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box! |
*************************************************
"Thalia Mei" <th*******@gmail.comwrote in message
news:4B**********************************@microsof t.com...
>Hi,

Would like to know what is the best way of creating an ASP.Net web page
that return just a line of "Text".

This ASP.Net will not required any HTML tag, or Post Back Features.

So we created below in Code Behind:

protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
Response.Clear();
Response.ContentType = "text/plain";

// Some Business Logic

Response.Write(sometext)
}

Is this the best way? The return result "sometext" will be used by
javascript (Ajax). But we still have this in our Form Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs"
Inherits="CUST_Test._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div></div>
</form>
</body>
</html>

Shall i remove all above from the Form Code?

Instead of protected override void Render(HtmlTextWriter writer), can we
just do something like this (probably in the Form Code):

<%
Response.Clear();
Response.ContentType = "text/plain";

// Some Business Logic

Response.Write(sometext)
%>

and then remove all Code Behind and everything, will that improve
performance?

Really appreciate if you can help. Millions Thanks!

Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: moondaddy | last post by:
I have an app where users will upload photos to their shopping cart. When they review their cart I need to include a light weight thumbnail of the image they uploaded. how can I take the image a...
18
by: Chris Hills | last post by:
A lesson in Posting How many C.L.C group posters does it take to change a C light bulb? 1 to change the light bulb and to post that the light bulb has been changed 14 to share similar...
0
by: Jerry J | last post by:
I have a text box that is validated using an asp:requiredfieldvalidator. There is an asp button control that posts back to the server. When the button is pressed, if there is no data in the text...
18
by: Diilb | last post by:
Hi All, I am not sure if this is the place to post this. But I am looking for a light weight drag and drop (sortable) library. I have looked around and there are a few good libraries...
3
by: virgil46 | last post by:
How do I for instance, fade the background color from dark gold at the top of the page to a light gold, by the time it gets to the bottom of the page?
4
by: YASIN786 | last post by:
Hi ol My name is yasin i am currently developing an application in vbnet 2003 the requirements are as follows: On the form will be located a number of points (no more than 4) through a light ray...
68
by: Santiago Romero | last post by:
( Surely if this question has been asked for a zillion of times... ) ( and sorry for my english! ) I'm impressed with python. I'm very happy with the language and I find Python+Pygame a very...
4
by: News | last post by:
hi i am Azhar (software engineer). i haveing face some problem in sliver light , textbox is not working in full screen.could any one tell me the soultion.
5
by: maheswaran | last post by:
Hi all, My home page have login button to login the users. Am trying to use lightbox method in login screen. Using this when user click the loing button, login form will appear with lightbox effect...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.