HTML and server conversation via ASP.NET

P

pamelafluente

Hi dears,

I have a plain HTML page.

I want to render it a little interactive. I was thinking to add to it 1
script and events to the elements I want to make interactive.

Then, I need to talk with an ASP.NET page which would actually do some
processing on the server. Processing may include a replace
(regeneration) of the above HTML page, for further interaction.

I have imagined the following scheme, but I need your advise to check
whether I am on the right track, or there are better or more elegant
ways to do that. Criticisms, suggestions, opinions are most welcome.

Here is my demo:


PLAIN HTML PAGE (want to add interactivity to some elements)
===============

<html>
<head><title>
Plain HTM page
</title>

<script type="text/javascript" language="JavaScript">
function Clicked(MyControlID)
{
var obj = document.getElementById("Messenger");
obj.value = MyControlID;
document.form1.submit();
}
</script>

</head>
<body>

<div id="Square1" style="width: 50px; height: 50px;
background-color:green" onclick = "Clicked('Square1')"></div>
<div id="Square2" style="width: 50px; height: 50px;
background-color:Red" onclick = "Clicked('Square2')"></div>

<form name="form1" method="get" action="AspProcessor.aspx"
id="form1">
<input type="hidden" name="ClickedElement" id="Messenger" />
</form>

</body>

</html>




ASP.NET PAGE (will process request and replace html)
============


Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Me.Page.Request.HttpMethod = "GET" Then

Response.Write(Me.Page.Request.QueryString("ClickedElement") & " was
clicked")

ElseIf Me.Page.Request.HttpMethod = "POST" Then
Response.Write(Me.Page.Request.Form("ClickedElement") & "
was clicked")

Else

MsgBox("Unexpected method " & Me.Page.Request.HttpMethod)

End If

End Sub

End Class
 
C

Cowboy \(Gregory A. Beamer\)

Having the page as an ASPX page, even if it really is not doing much, is no
a big deal. What you are waiming at here sounds a lot like AJAX. On the
asp.net site, there is a tool called Atlas for including Ajax in your apps.
It is still beta. There is also Ajax.net, an open source implementation.
Essentially, Atlas or Ajax.net use JavaScript to send XML messages back to
the server for the dynamic bits.

Can you go with the plain HTML and a JavaScript submit? Sure, but why should
you have to debug all the infrastructure code, esp. client side which is a
real pain, when you can have that part handled by someone else.

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

*************************************************
Think Outside the Box!
*************************************************
 
P

pamelafluente

Thanks Gregory,

I explain better my contex, so you can focus better your suggestions.

I have a (say "server") application which generates reports in form of
html files. These html file are *extremely* complicated and could not
be done (in practice) as ASP pages. They are generated in no time
through brutal writing on disk of the html code (streamwriter).

Now, one would like to add web interactivity to these html reports. For
instance, when one clicks on a cell a drill down could occur (etc...).
The request could be sent to the server (through the mechanism I
schetcked above) and the html report immediately regenerated to show
the new report (eg, drilled down).

This architecture would have 2 advantages (that i can see now):
1. Html reports can be ported wherever and still be used as plain html
(if does not want to interact)
2. Reports can be very complex in design and are generated at light
speed.

Thanks for any advice or comment

-p

Cowboy (Gregory A. Beamer) ha scritto:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top