simulate button click

X

xzzy

I have several pages in a frame and need the code behind of a page in one of
the frames to cause a button in that page to click so the javascript in that
button will execute on the client computer..

Thank you,

John Bickmore
 
K

Kevin Spencer

Use Page.RegisterStartupScript to add a JavaScript to the page that clicks
the button.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.
 
J

Jim Suruda

John-

You can try something like such:

this.Response.Redirect("WebForm1.aspx?__EVENTTARGET=ButtonA");

If you have a button called ButtonA, this code will redirect the browser
to WebForm1 and trigger the event handler for the button. (It is indeed
two underscores before EVENTTARGET)

Hope this helps,
Jim Suruda
 
X

xzzy

this.Response.Redirect("WebForm1.aspx?__EVENTTARGET=ButtonA");

Does execute ButtonA 's code in that page after loading into the frame

but does not actually "click" ButtonA

I need to "click" ButtonA because it just had different javascript added to
Attributes that needs to be executed
 
X

xzzy

the next reply in the thread - from Jim Suruda -
that code does fire the code behind named ButtonA_OnClick, but it does not
click the button

clicking the button is important because
ButtonA just had different javascript added to Attributes that needs to
be executed


PS Kevin
You can lead a fish to a bicycle, but you can't make it stink.

actually, you can lead a swimmer to a bicycle and they race faster in the
rain
 
K

Kevin Spencer

PS Kevin
actually, you can lead a swimmer to a bicycle and they race faster in the
rain

Cute! But it doesn't sound anything like the original "horse to water"
saying. So, my Uncle Chutney would never go for it. He likes to play around
with old sayings, to give them new meaning. I must admit, though, the new
meaning in this case is a mystery to me! Oh well, as Uncle Chutney sez,
"Ambiguity has a certain quality to it."

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.
 
X

xzzy

Kevin, your suggestion about RegisterStartupScript got me thinking that if
I was okay with not clicking a button and thus having to load a different
page into that frame, then this works:

Thanks for your help,
John

PS I find it funny that the more I do .net, the more I learn Javascript



Code behind:
// the next line means: in this frame, replace the page belonging to
this code behind with Blank.htm
this.Response.Redirect("blank.htm");


Blank.htm
<script language="javascript">
function IveBeenSlimed()
{
do things here
}
</script>
<html>
<head>
<title></title>
</head>
<body onload="IveBeenSlimed()">
</body>
</html>
 
K

Kevin Spencer

Hi John,
PS I find it funny that the more I do .net, the more I learn Javascript

Shouldn't be funny at all. It's not .Net per se, but ASP.Net. To do ASP.Net,
one must learn and understand a wide variety of disciplines, including HTML,
CSS, JavaScript, XML, HTTP, SOAP, web server technology, etc. It's a lot
harder than writing Windows desktop apps! I can't tell you how many hours
I've spent poring over sites like the W3C web site, the ECMA web site, etc.
etc. My voluminous collection of bookmarks speaks for itself!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.
 

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

No members online now.

Forum statistics

Threads
473,787
Messages
2,569,630
Members
45,334
Latest member
66Zeinab9

Latest Threads

Top