473,657 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET suppress response HTML

I have an ASP.NET webpage that allows a user to upload a file from the
client browser. I want to display an animated gif and report on the
progress of the upload. The <INPUTtag used for uploading files
requires the form to be posted. Posts stop javascripts and GIF
animations from running for the duration of the upload until a
response to the post is received from the codebehind and the page is
re-rendered.

To get around this problem, I'm posting the upload through an XMLHTTP
control from a client-side javascript function instead. The XMLHTTP
control runs in parallel with the browser, so javascript and GIF
animations are able to continue to run simultaneously with the upload
as it is happening.

This works very well, and the asp.net codebehind generates its regular
response of the source code for its corresponding HTML .aspx page.
The XMLHTTP control, and not the browser, receives the codebehind's
response. As the current page the control is on is still visible in
the browser, and the XMLHTTP control doesn't re-render pages, the
returned HTML code is of little use.

It would be great if there was some way to shutdown the automatic
generation of HTML by the codebehind for its responses to the XMLHTTP
control's requests, and instead use the responses to send back
meaningful messages.

In the codebehind's Page_Load function, I've tried:
Response.Suppre ssContent = True
Response.Cache. SetNoStore()
Response.ClearC ontent()
Response.Clear( )
Response.End()

But, the HTML is still being generated and returned as evidenced by
using an alert box in the clientside code on the XMLHTTP control's
received contents.

All I want is to be able to do a:
Response.Write( "My message")

without the codebehind generating any other content automatically.

Does anyone know how to do this?

thanks in advance,
Andy

May 30 '07 #1
3 2307
as long as buffer is on, ClearContent(), Response.End() works fine.

the only problem with using XMLHTTPResquest to upload, is the user
having to turn on full trust for your site. be sure there are no cross
scripting errors on you site, or it can be used for security exploits.

-- bruce (sqlwork.com)

Andy wrote:
I have an ASP.NET webpage that allows a user to upload a file from the
client browser. I want to display an animated gif and report on the
progress of the upload. The <INPUTtag used for uploading files
requires the form to be posted. Posts stop javascripts and GIF
animations from running for the duration of the upload until a
response to the post is received from the codebehind and the page is
re-rendered.

To get around this problem, I'm posting the upload through an XMLHTTP
control from a client-side javascript function instead. The XMLHTTP
control runs in parallel with the browser, so javascript and GIF
animations are able to continue to run simultaneously with the upload
as it is happening.

This works very well, and the asp.net codebehind generates its regular
response of the source code for its corresponding HTML .aspx page.
The XMLHTTP control, and not the browser, receives the codebehind's
response. As the current page the control is on is still visible in
the browser, and the XMLHTTP control doesn't re-render pages, the
returned HTML code is of little use.

It would be great if there was some way to shutdown the automatic
generation of HTML by the codebehind for its responses to the XMLHTTP
control's requests, and instead use the responses to send back
meaningful messages.

In the codebehind's Page_Load function, I've tried:
Response.Suppre ssContent = True
Response.Cache. SetNoStore()
Response.ClearC ontent()
Response.Clear( )
Response.End()

But, the HTML is still being generated and returned as evidenced by
using an alert box in the clientside code on the XMLHTTP control's
received contents.

All I want is to be able to do a:
Response.Write( "My message")

without the codebehind generating any other content automatically.

Does anyone know how to do this?

thanks in advance,
Andy
May 30 '07 #2
Thanks for your response...

I've got:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Response.Buffer = True 'allows content to be cancelled

and later I have:
result = Upload(False) 'this uploads the file
and returns a status
Response.Suppre ssContent = True
Response.ClearC ontent()
Response.Clear( )

Response.Write( result)

But, I still get the HTML for the page returned

What am I doing wrong?


May 31 '07 #3
Found the problem.

A post from the XMLHTTP control to an ASP.NET web page will always be
considered to be a first time page load and never a page postback by
the codebehind, regardless if the XMLHTTP control is posting from a
currently displayed asp.net page that has already experienced its
first load.

So, server-side code in the codebehind that is nested inside a
Page.IsPostBack if statement will never get executed.

This is because the hidden asp.net viewstate field isn't populated or
transmitted when the client-side XMLHTTP control makes its post.

The solution is to remove any Page.IsPostBack statements in the
codebehind's Page_Load function, and to control whether code that
should be executed only when a page is posted back (from the client's
perspective) through regular querystring posted values.
May 31 '07 #4

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

Similar topics

1
1549
by: Todd | last post by:
I am trying to mimic the html anchor tag. I have created a class; Public Class anchor <XmlAttributeAttribute()> _ Public href As String Public title As String End Class and get the following XML;
3
1533
by: peshrad | last post by:
Hi ! I'm using ASP.NET 1.1 and C# . For Microsoft Internet Explorer 6.0, the following code suppresses the drawing of horizontal and vertical lines in the web page:
1
1725
by: tertullian | last post by:
I have a page that tries to forward the page using javascript every minute. However, I have to write it so that if the computer were to lose internet connection it would appear to the user as though nothing has changed and try to refresh again in a minute. I have everything working except for if the computer loses internet connection it throws up a browser error that the page cannot be reached. Is there anyway to suppress that browser...
2
10766
by: samir.kuthiala | last post by:
I do some requests in the background on a page using the XMLHttpRequest object. My site uses NTLM Authentication. However if the user is not logged in, it throws up an ugly dialog box. Is there any way to suppress this? I am ok with the object throwing an error which I can catch. What I want to do is to make a request. Instead of it popping up a dialog box, I want to be able to suppress this dialog and instead forward him to a...
9
1440
by: sinbuzz | last post by:
People, Most browsers allow me to suppress viewing of images when I browse a URL. Can this behavior be duplicated by the server? I'd like for my server to detect if a user has image viewing turned off in his browser.
4
9946
by: =?Utf-8?B?UmljaA==?= | last post by:
When I press the Enter key in a Textbox I get a beep sound. But when I press the Enter key in a combobox, I don't get the beep sound. Is there a way to suppress the beep? How to do this? Thanks
2
6637
by: ZeeHseez | last post by:
Hi, I have written a webbrowser application in VB .net Framework 1.1. I would like to suppress javascript error messages. However, the silent property of the webbrowser control suppresses the Javascript messages, but it also blocks any other dialog box, such as Login dialog, i can't use the silent property. I used http://support.microsoft.com/default.aspx?scid=kb;EN-US;279535 article to suppress the error messages. It works fine until a...
1
1216
by: Ahmet Gunes | last post by:
Hello, I am developing a custom control. From within this control, maybe during/before rendering, I want to totally clear the response content and only render this control's output. Since the Render event of the page is protected I can not attach an event handler at runtime. When I use Response.Clear() and/or Response.ClearContent() and/or delete controls from the Controls collection of the Page I still get the closing tags of form,...
0
8413
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8740
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.