call server side function then javascript

  • Thread starter Lostdante via DotNetMonster.com
  • Start date
L

Lostdante via DotNetMonster.com

Hi,

I have a modal dialog box which i'm using to collect user data. what I want
to do is when the user clicks the 'submit' button add the data to the
database and then call the java script to close the window and pass a value
back to the parent page.

I've tried using RegisterStartupScript after the database update function but
this doesn't seem to work. Any help would be great.

Rob.

Code is:
'add data to db
addAction()

'close window
Dim strScript, strKey
strKey = "AddAction"
strScript = "<script language=JavaScript>window.returnValue = document.
getElementById('txtlbID').value; window.close();</script>"

Page.RegisterStartupScript(strKey, strScript)
 
L

Lostdante via DotNetMonster.com

Peter said:
Try Response.Write (yourscript) instead

Peter
[quoted text clipped - 19 lines]
Page.RegisterStartupScript(strKey, strScript)

Hi Peter,

Thanks for the reply. I tried the response.write after the db update function
but nothing happend and other thoguhts?

strScript = "<script language=JavaScript>window.returnValue = document.
getElementById('txtlbID').value; window.close();</script>"

Response.Write(strScript)

Rob
 
G

Guest

It sounds then like you have some sort of postback and your data is now gone.
You could try Viewstate, or a hidden form field. You can also call an update
method on the parent page with
window.parent.Update(document.getElementById('txtlbID').Value);
then--
window.close();

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




Lostdante via DotNetMonster.com said:
Peter said:
Try Response.Write (yourscript) instead

Peter
[quoted text clipped - 19 lines]
Page.RegisterStartupScript(strKey, strScript)

Hi Peter,

Thanks for the reply. I tried the response.write after the db update function
but nothing happend and other thoguhts?

strScript = "<script language=JavaScript>window.returnValue = document.
getElementById('txtlbID').value; window.close();</script>"

Response.Write(strScript)

Rob
 
K

Kevin Spencer

Have you looked at the client-side HTML that is in the browser to see
whether or not your JavaScript is there?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
 
L

Lostdante via DotNetMonster.com

Peter said:
It sounds then like you have some sort of postback and your data is now gone.
You could try Viewstate, or a hidden form field. You can also call an update
method on the parent page with
window.parent.Update(document.getElementById('txtlbID').Value);
then--
window.close();
[quoted text clipped - 17 lines]

Passing the value back is less of a problem. What I need to resolve is how to
call the window.close event after the update db function is called in the
button click event.

Is it possible to call javascript from within the click event after a server
side call?
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top