Pass value from javascript to vb.net to database without postback...Possible?

A

Andy

Hi,

I have a complicated question that I'm hoping someone can help me out
with. I have a webpage that contains a plug-in. This plug-in can
communicate/pass data with the webpage that contains it via javascript.
What I need to be able to do is take that data passed via javascript
and, using vb.net as the code behind language, send it to a database
without posting it because when I post, the plugin is reloaded and
starts at the beginning. Specifcally, the plug-in is a type of
educational program, when the user completes a certain objective in the
program, I need to store that info in the database but not have the
program start back at the beginning.

What happens currently is upon completing the objective in the plugin,
a javascript function is called in the containing webpage. That
javascript function changes the data in a hidden field runat the
server. I artificially create a postback using the
document.forms.submit() function, then in the page_load function in the
codebehind page I check the value of the hidden field and store it to
the database. This works fine. The problem is that when the page
reloads, my plug-in is reloaded and instead of the user being at say
level 6, they are back at the initial level 1. Ideally, I would like to
send the information to the database without having to reload the page
and was wondering if this was possible.

Thanks in advance and I'll be happy to clarify any questions.

Andy
 
M

Marina

You would need to do something like use XMLHTTP to issue a call to a page to
do the work. However, I think that ties you to IE 5.5 and above. This may
or may not be a problem for you.
 
B

Bruce Barker

the easiest approach is a hidden iframe/frame.

1) the src of the hidden frame should be an aspx page with hidden fields.
the clientscript would fill in the hidden fields in the frame, and do a
submit of the frame.

2) create an addtional form (nonserver) on the page with the target the
hidden frame, have the client script fill in the hidden fields in the form
and do a submit.

-- bruce (sqlwork.com)
 
A

Andy

Thanks everyone for their help. It seems that ajax is probably going to
be the way I go. I tried to avoid it since I'm pretty new to this web
programming and didn't understand if it was for me, but it seems that's
what I need long term. One quick question, I've been using asp.net 2.0
but because it is in its beta form, I have avoided exploiting much of
its newer features. How worried do I have to be about creating a
website in 2.0 beta then having it not work on me when the final
release comes out?
 
G

Guest

Be very worried! Well, not to scare you or anything but seriously, any new
product in beta is not going to be 100% reliable. That's why they call it
alpha, beta.
That being said, you can do a search on google for a list of issues in beta,
that way you can be aware of what's going to work on final release.
 

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

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,216
Latest member
topweb3twitterchannels

Latest Threads

Top