Save button and AJAX in ASP.NET 1.1

G

Guest

Hi,

I'm wondering if anyone can help me with AJAX in ASP.NET 1.1. I have a very
specific feature that I would like to use it for.

I have a rather long form that the users use to enter data during a phone
call with a client. Since it's long, I put six Save buttons down the length
of the form and asked the users to save often. When they click the Save
buttons, the data is saved to a central database and a text label is changed
to say "successful" or "unsuccessful."

Since this involves a postback to the server, I turned on Smart Navigation
so that the focus would stay at the same position. I didn't want the users
to have to scroll down the length of the form every time they clicked Save.

But we're having problems with Smart Navigation.

So, my question is can I use AJAX to do the Save? I just want to send the
data to the central database without a postback. The only change to the
interface would be to return a "successful" or "unsuccessful" message. Can
anyone advise me on how to do this in 1.1?

I pasted some code below. Let me know if it would help to see the code for
the SaveData function.

Thanks!
Chris

============================

Each Save button has this behind it:

Private Sub btnSave1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave1.Click
If Page.IsValid Then
lblSave1.Visible = True
If SaveData() Then
lblSave1.Text = "Successfully saved."
Else
lblSave1.Text = "An error occurred. " & Session("ErrMsg")
End If
End If
End Sub

===============================
 
G

Guest

Yes, you can use AJAX to accomplish this. You will have to write quite a bit
of javascript to accomplish this task if you have a lot of fields that need
to be saved.

Depending on how well you know JavaScript, this could be a pretty big task.
 
G

Guest

Thanks for the heads up.

A hotfix for the SmartNav problem is mentioned in this Microsoft article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;884022

The article recommends waiting for the next Microsoft Visual Studio .NET
2003 service pack that contains the hotfix.

This page has some info about the service pack:
http://msdn.microsoft.com/vstudio/support/servicing/sp1_vs03/default.aspx

“A customer beta period for Visual Studio 2003 SP1 begins March 24, 2006 and
will continue through April 24, 2006.â€

Do you know if this means the service pack would be available to everyone
after April 24th? Or would there be a delay? I don’t really follow service
pack releases.

Thanks.
 
G

Guest

My guess is it will be available shortly after April 24th as long as they
don't have any problems they need to fix that would take a long time.
 
D

don.schenck

Sorry I'm so late to the party.

But as long as you're going to allow as-you-go updates, you might as
well include what's known as the "Yellow Fade Technique" (Google it)
for the updated fields. Also, the label that reads "Successful" could
display that for, say, five seconds and then fade away. Or else toggle
to blanks or "Changed" or some other status to indicate that a Save is
needed. The toggle would happen on any keypress that makes the form
dirty.

My two cents.
 
B

bruce barker \(sqlwork.com\)

while ajax will work, you can do a old fashioned post to a hidden frame:

create a hidden iframe on the page.

<iframe name=hiddenPost id =hiddenPost style="width:0;height:0;"></iframe>

a label(s) to update with satatus

<span id="savestatus1"></span>

then the save buttons

<asp:button id=save1 runat=server>

in the codebehind

save1.Attributes["onclick"] = "forms[0].target='hiddenPost';"

for the final save:

donesave.Attributes["onclick"] = "forms[0].target='_self';"

when the users click the save button, a post will be done using the hidden
frame, so the focus will not move. when your code behind get a postback from
save1, it should save the data and write the following javascript. (its best
that clear the response and only write the following code)

<script>
var el = window.parent.document.getElementById(savestatus1);
if (el) el.innerHTML = "Saved";
</script>

-- bruce (sqlwork.com)
 

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