473,394 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

call server side function then javascript

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)

--
Message posted via http://www.dotnetmonster.com
Jan 18 '06 #1
5 1578
Try Response.Write (yourscript) instead

Peter

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


"Lostdante via DotNetMonster.com" wrote:
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)

--
Message posted via http://www.dotnetmonster.com

Jan 18 '06 #2
Peter Bromberg [C# MVP] wrote:
Try Response.Write (yourscript) instead

Peter
Hi,

[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

--
Message posted via http://www.dotnetmonster.com
Jan 18 '06 #3
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('txtl bID').Value);
then--
window.close();

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


"Lostdante via DotNetMonster.com" wrote:
Peter Bromberg [C# MVP] wrote:
Try Response.Write (yourscript) instead

Peter
Hi,

[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

--
Message posted via http://www.dotnetmonster.com

Jan 18 '06 #4
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.

"Lostdante via DotNetMonster.com" <u12359@uwe> wrote in message
news:5a89d3801f9e7@uwe...
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)

--
Message posted via http://www.dotnetmonster.com

Jan 18 '06 #5
Peter Bromberg [C# MVP] wrote:
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('txt lbID').Value);
then--
window.close();
>Try Response.Write (yourscript) instead
>

[quoted text clipped - 17 lines]

Rob


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?

--
Message posted via http://www.dotnetmonster.com
Jan 18 '06 #6

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

Similar topics

15
by: chirs | last post by:
I am trying to understand a piece of code. In a javascrpit file, there is a function: function ItemStyle(){ var names=; addProps(this,arguments,names,true); }; In the html file, it calls...
12
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank,...
1
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when...
1
by: Mike Moore | last post by:
Can an asp.net button that is a server side control call a client side java function when the button is clicked? If so, please provide example.....thanks.,
3
by: David Shorthouse | last post by:
Hey folks, Not an off-topic posting.....since I was shot-down in an earlier post...this one's legit. How do I go about calling a server-side vbscript within a client-side javascript function?...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
3
by: lanem | last post by:
I want to call a server-side function, like a button's click event, from a client-side JavaScript function. How do I do that? Thanks.
4
by: abcd | last post by:
I am novice asp.net programmer. I have xyz.js file which has resuable functions. I have asp.net form abcd.aspx and the code behind file abcd.aspx.cs, I want to put a 'Help' button when clicked...
6
by: den 2005 | last post by:
Hi everybody, Question 1: How do you set the values from server-side to a client-side control or how do you execute a javascript function without a button click event? Question 2: How do you...
0
AnuSumesh
by: AnuSumesh | last post by:
Hi All, I am trying to call RDP on click of link. 'n' I am using following code to do this: <script language="javascript"> function setip(ip) { var wshell;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.