RE: Code to "click" a button -- is this possible?
- From: Ben <ben_1_ AT hotmail DOT com>
- Date: Wed, 17 May 2006 07:22:02 -0700
Michael
The error I am getting is a compile time error and not a runtime error. I'm
using VS2003 (C#).
I hate to keep bugging you, but I don't have an idea on how to fix this.
Thanks.
"Michael Nemtsev" wrote:
Check that you already have the button's handler..
Because you are trying to call non-exited button's handler;
"Ben" wrote:
Sorry, I guess I forgot to paste my exact code line aswell...here it is:
(Page.FindControl("btnTest") as Button).Click.Invoke(this, new EventArgs());
And I am recieving the error as described by my last post.
Thanks again for all the help! Hopefully this will be resolved soon.
Ben
"Michael Nemtsev" wrote:
Not jut Click but Button2.Click.Invoke(...);
"Ben" wrote:
Michael
thank you for the reply...this is looking like what i was trying to achieve.
I have tried the code and recieved the following error:
The event 'System.Web.UI.WebControls.Button.Click' can only appear on the
left hand side of += or -=
any suggestions?
thanks.
ben
"Michael Nemtsev" wrote:
Use Page.FindControl() with the name of your control to get you button, cast
to the Button class and call .Click.Invoke method
Smth like (Page.FindControl("Button2") as Button).Click.Invoke(this, new
EventArgs());
thank you for your reply.
first...im new to web development so i do not understand all the concepts.
the application im creating has 2 frames. the left is a treeview menu and
the right shows the data. When a user navigates through the right frame, i
have code to update the left frame:
private void dgGroup_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
string id = "g" + e.Item.Cells[3].Text;
e.Item.Cells[2].Attributes.Add("onclick", "if(syncNode('" + id +
"')){}else{return false}");
}
however, another control on the same page would be to delete the item (and
hense, delete the item from the leftfram aswell). If i use this same
principle to refresh the left frame, it occurs BEFORE the item gets deleted.
I need the refresh to occur after. Hense why I was looking to see if i can
programmically click a button from my C# code to fire the onclick event of
the button.
I hope this clears it up a little, i need this to work. thanks.
ben
"Michael Nemtsev" wrote:
Why not to use window.location.href and javascript for this ?
I have frames set up in an asp.net application and need one frame to refresh
another. Seeing as events need to be registered at the time the page is sent
from the server, I was wondering if I could place a hidden button in a frame
that would have the attribute to refresh the other. I would need code to
"invoke" the onclick event (ie i need code to click the button).
--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
- References:
- RE: Code to "click" a button -- is this possible?
- From: Michael Nemtsev
- RE: Code to "click" a button -- is this possible?
- From: Ben
- RE: Code to "click" a button -- is this possible?
- From: Michael Nemtsev
- RE: Code to "click" a button -- is this possible?
- Prev by Date: Re: Reverse Sorting ListView with Right-Click
- Next by Date: Re: Return a boolean or raise an exception (from a LogOn method)?
- Previous by thread: RE: Code to "click" a button -- is this possible?
- Next by thread: show a windows form in front of an arbitrary fullscreen application
- Index(es):
Loading