By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

Execute Javascript AFTER click event

P: n/a
Hi All,
I have an .net form that is split into two frames. The left frame has a
tree that displays a list of all the customers. The right frame displays
the appropriate clients information. When the save button is pressed on the
right frame, I want to update the tree in the left frame AFTER saving all
the data as the changes to the right frame may affect how the tree is
displayed. I tried using the following:

btnSave.Attributes("onclick") = "top.frames['search'].location.href =
'SearchTree.aspx';"

The only issue is that the above javascript executes BEFORE the server side
click event. So what I need to be able to do is either

1) call a javascript from vb.net whenever I want OR
2) without javascript, refresh a frame from another frame OR
3) somehow have the clientside script execute AFTER the serverside
script
Any help, with examples, would be greatly appreciated.

Thanks
Ian
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Ian,

3) is the way to go. Make a hidden input for passing instructions from
server to client. Make a client-side <body .. onload=..> event that will
read the input and handle the instruction if any. Normally, the input will
be empty. When you want to tell the client to update the tree, pass a word
"UPDATETREE". The client side onload event will get the word and execute
top.frames['search'].location.href = 'SearchTree.aspx';

Eliyahu

"Ian Kelly" <in**@thetawave.on.ca> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi All,
I have an .net form that is split into two frames. The left frame has a
tree that displays a list of all the customers. The right frame displays
the appropriate clients information. When the save button is pressed on the right frame, I want to update the tree in the left frame AFTER saving all
the data as the changes to the right frame may affect how the tree is
displayed. I tried using the following:

btnSave.Attributes("onclick") = "top.frames['search'].location.href =
'SearchTree.aspx';"

The only issue is that the above javascript executes BEFORE the server side click event. So what I need to be able to do is either

1) call a javascript from vb.net whenever I want OR
2) without javascript, refresh a frame from another frame OR
3) somehow have the clientside script execute AFTER the serverside
script
Any help, with examples, would be greatly appreciated.

Thanks
Ian

Nov 19 '05 #2

P: n/a
Hi Eliyahu,
Thanks for your suggestion. I should have given some info on my background.
I am a VB 6.0 programmer. VB.NET is very new to me. I think I got most of
what you were suggesting, but could I get some more detail. Sorry.

Ian
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Ian,

3) is the way to go. Make a hidden input for passing instructions from
server to client. Make a client-side <body .. onload=..> event that will
read the input and handle the instruction if any. Normally, the input will
be empty. When you want to tell the client to update the tree, pass a word
"UPDATETREE". The client side onload event will get the word and execute
top.frames['search'].location.href = 'SearchTree.aspx';

Eliyahu

"Ian Kelly" <in**@thetawave.on.ca> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi All,
I have an .net form that is split into two frames. The left frame has a
tree that displays a list of all the customers. The right frame displays
the appropriate clients information. When the save button is pressed on

the
right frame, I want to update the tree in the left frame AFTER saving all
the data as the changes to the right frame may affect how the tree is
displayed. I tried using the following:

btnSave.Attributes("onclick") = "top.frames['search'].location.href =
'SearchTree.aspx';"

The only issue is that the above javascript executes BEFORE the server

side
click event. So what I need to be able to do is either

1) call a javascript from vb.net whenever I want OR
2) without javascript, refresh a frame from another frame OR
3) somehow have the clientside script execute AFTER the serverside
script
Any help, with examples, would be greatly appreciated.

Thanks
Ian


Nov 19 '05 #3

P: n/a
Ian,

Put in your .aspx file just before the </form> tag a line:
<input type=hidden id=inhAction runat=server>
Here you will pass action instructions from server to client.
After switching to design view and back to html view it will add a
HtmlInputHidden control named inhAction to yoour code behind.

In the Page_Load server event put a line:
inhAction.Value=""
This will preset the action to empty string.

At the end of your server-side event that handles the save button click put
a line:
inhAction.Value="UPDATETREE"

Go back to the .aspx page and make your <body> looking as
<body onload="handleAction()">

In the <head> section of the .aspx page add a javascript::
<script language="javascript">
function handleAction(){
if (Form1.inhAction.value=="UPDATETREE")
top.frames['search'].location.href = 'SearchTree.aspx';
}
</script>

That's about it.

Eliyahu

"Ian Kelly" <in**@thetawave.on.ca> wrote in message
news:OE**************@tk2msftngp13.phx.gbl...
Hi Eliyahu,
Thanks for your suggestion. I should have given some info on my background. I am a VB 6.0 programmer. VB.NET is very new to me. I think I got most of what you were suggesting, but could I get some more detail. Sorry.

Ian
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Ian,

3) is the way to go. Make a hidden input for passing instructions from
server to client. Make a client-side <body .. onload=..> event that will
read the input and handle the instruction if any. Normally, the input will be empty. When you want to tell the client to update the tree, pass a word "UPDATETREE". The client side onload event will get the word and execute
top.frames['search'].location.href = 'SearchTree.aspx';

Eliyahu

"Ian Kelly" <in**@thetawave.on.ca> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi All,
I have an .net form that is split into two frames. The left frame has a tree that displays a list of all the customers. The right frame displays the appropriate clients information. When the save button is pressed on
the
right frame, I want to update the tree in the left frame AFTER saving

all the data as the changes to the right frame may affect how the tree is
displayed. I tried using the following:

btnSave.Attributes("onclick") = "top.frames['search'].location.href =
'SearchTree.aspx';"

The only issue is that the above javascript executes BEFORE the server

side
click event. So what I need to be able to do is either

1) call a javascript from vb.net whenever I want OR
2) without javascript, refresh a frame from another frame OR
3) somehow have the clientside script execute AFTER the serverside script
Any help, with examples, would be greatly appreciated.

Thanks
Ian



Nov 19 '05 #4

P: n/a
Eliyahu,
I just got in and tried this. It works VERY well.

Thank you very much.

Ian
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:Ob**************@tk2msftngp13.phx.gbl...
Ian,

Put in your .aspx file just before the </form> tag a line:
<input type=hidden id=inhAction runat=server>
Here you will pass action instructions from server to client.
After switching to design view and back to html view it will add a
HtmlInputHidden control named inhAction to yoour code behind.

In the Page_Load server event put a line:
inhAction.Value=""
This will preset the action to empty string.

At the end of your server-side event that handles the save button click
put
a line:
inhAction.Value="UPDATETREE"

Go back to the .aspx page and make your <body> looking as
<body onload="handleAction()">

In the <head> section of the .aspx page add a javascript::
<script language="javascript">
function handleAction(){
if (Form1.inhAction.value=="UPDATETREE")
top.frames['search'].location.href = 'SearchTree.aspx';
}
</script>

That's about it.

Eliyahu

"Ian Kelly" <in**@thetawave.on.ca> wrote in message
news:OE**************@tk2msftngp13.phx.gbl...
Hi Eliyahu,
Thanks for your suggestion. I should have given some info on my

background.
I am a VB 6.0 programmer. VB.NET is very new to me. I think I got most

of
what you were suggesting, but could I get some more detail. Sorry.

Ian
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> Ian,
>
> 3) is the way to go. Make a hidden input for passing instructions from
> server to client. Make a client-side <body .. onload=..> event that
> will
> read the input and handle the instruction if any. Normally, the input will > be empty. When you want to tell the client to update the tree, pass a word > "UPDATETREE". The client side onload event will get the word and
> execute
> top.frames['search'].location.href = 'SearchTree.aspx';
>
> Eliyahu
>
> "Ian Kelly" <in**@thetawave.on.ca> wrote in message
> news:%2****************@TK2MSFTNGP09.phx.gbl...
>> Hi All,
>> I have an .net form that is split into two frames. The left frame has a >> tree that displays a list of all the customers. The right frame displays >> the appropriate clients information. When the save button is pressed on > the
>> right frame, I want to update the tree in the left frame AFTER saving all >> the data as the changes to the right frame may affect how the tree is
>> displayed. I tried using the following:
>>
>> btnSave.Attributes("onclick") = "top.frames['search'].location.href =
>> 'SearchTree.aspx';"
>>
>> The only issue is that the above javascript executes BEFORE the server
> side
>> click event. So what I need to be able to do is either
>>
>> 1) call a javascript from vb.net whenever I want OR
>> 2) without javascript, refresh a frame from another frame OR
>> 3) somehow have the clientside script execute AFTER the serverside >> script
>>
>>
>> Any help, with examples, would be greatly appreciated.
>>
>> Thanks
>> Ian
>>
>>
>
>



Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.