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

Code to "click" a button -- is this possible?

P: n/a
Ben
Hello

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).

is this possible?
thanks.
ben
May 17 '06 #1
Share this Question
Share on Google+
21 Replies


P: n/a
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

May 17 '06 #2

P: n/a
Ben
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

May 17 '06 #3

P: n/a
Hi,

"Ben" <ben_1_ AT hotmail DOT com> wrote in message
news:84**********************************@microsof t.com...
Hello

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).

is this possible?


you can refresh any of the frames using javascript, you can either Refresh
the frame, submit the form , or call a method to a control (like button
click ) these actions will refresh the form
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

May 17 '06 #4

P: n/a
Ben
could you please supply the code that can be called from the C# method that
will refresh another frame called "Main"?

thanks. I am not familiar with javascripting.

ben

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

"Ben" <ben_1_ AT hotmail DOT com> wrote in message
news:84**********************************@microsof t.com...
Hello

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).

is this possible?


you can refresh any of the frames using javascript, you can either Refresh
the frame, submit the form , or call a method to a control (like button
click ) these actions will refresh the form
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

May 17 '06 #5

P: n/a
Ben,

I would not be C# code. It would be javascript. Once the client receives
the HTML output from the ASP.NET page, C# no longer has any control (its all
on the client now). It is important to understand the distinction between
server-side and client-side which is inherit in all dynamic web applications.
The server sends HTML, CSS, and javascript (or jscript or vbscript) to the
client. The client (an Internet Browser, like IE or FireFox) then decides
what to do with the HTML, CSS, and script that was sent to it. One way to
look at is that the web server simply makes a suggestion to the browser. It
suggests it should render certain UI elements and run certain client-side
scripts. Its up to the browser to comply. It doesn't have to. The web
server can't control the actions of the browser. For instance, if a browser
has scripting disabled or isn't compliant with all the CSS that was sent to
it... then it will look and act very differently than it was designed to.
There are ways around this, but it involves detecting the capabilities of the
browser that made a request for the page.

Now, to answer your question. Here is the javascript used to reload a iframe:

<iframe name='content'></iframe>
<script language='javascript'>
parent.frames.item('content').location.href = 'mypage.aspx';
</script>

"Ben" wrote:
could you please supply the code that can be called from the C# method that
will refresh another frame called "Main"?

thanks. I am not familiar with javascripting.

ben

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

"Ben" <ben_1_ AT hotmail DOT com> wrote in message
news:84**********************************@microsof t.com...
Hello

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).

is this possible?


you can refresh any of the frames using javascript, you can either Refresh
the frame, submit the form , or call a method to a control (like button
click ) these actions will refresh the form
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

May 17 '06 #6

P: n/a
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

May 17 '06 #7

P: n/a
Ben
Nate
thank you for your reply

are you telling me there is no way that i can then refresh a specific frame
AFTER the server side code is run? that is what i require...ie a way of
calling the javascript you provided.

thanks.

"Nate" wrote:
Ben,

I would not be C# code. It would be javascript. Once the client receives
the HTML output from the ASP.NET page, C# no longer has any control (its all
on the client now). It is important to understand the distinction between
server-side and client-side which is inherit in all dynamic web applications.
The server sends HTML, CSS, and javascript (or jscript or vbscript) to the
client. The client (an Internet Browser, like IE or FireFox) then decides
what to do with the HTML, CSS, and script that was sent to it. One way to
look at is that the web server simply makes a suggestion to the browser. It
suggests it should render certain UI elements and run certain client-side
scripts. Its up to the browser to comply. It doesn't have to. The web
server can't control the actions of the browser. For instance, if a browser
has scripting disabled or isn't compliant with all the CSS that was sent to
it... then it will look and act very differently than it was designed to.
There are ways around this, but it involves detecting the capabilities of the
browser that made a request for the page.

Now, to answer your question. Here is the javascript used to reload a iframe:

<iframe name='content'></iframe>
<script language='javascript'>
parent.frames.item('content').location.href = 'mypage.aspx';
</script>

"Ben" wrote:
could you please supply the code that can be called from the C# method that
will refresh another frame called "Main"?

thanks. I am not familiar with javascripting.

ben

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

"Ben" <ben_1_ AT hotmail DOT com> wrote in message
news:84**********************************@microsof t.com...
> Hello
>
> 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).
>
> is this possible?

you can refresh any of the frames using javascript, you can either Refresh
the frame, submit the form , or call a method to a control (like button
click ) these actions will refresh the form
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

May 17 '06 #8

P: n/a
Ben
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

May 17 '06 #9

P: n/a
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

May 17 '06 #10

P: n/a
Ben
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

"Nate" wrote:
Ben,

I would not be C# code. It would be javascript. Once the client receives
the HTML output from the ASP.NET page, C# no longer has any control (its all
on the client now). It is important to understand the distinction between
server-side and client-side which is inherit in all dynamic web applications.
The server sends HTML, CSS, and javascript (or jscript or vbscript) to the
client. The client (an Internet Browser, like IE or FireFox) then decides
what to do with the HTML, CSS, and script that was sent to it. One way to
look at is that the web server simply makes a suggestion to the browser. It
suggests it should render certain UI elements and run certain client-side
scripts. Its up to the browser to comply. It doesn't have to. The web
server can't control the actions of the browser. For instance, if a browser
has scripting disabled or isn't compliant with all the CSS that was sent to
it... then it will look and act very differently than it was designed to.
There are ways around this, but it involves detecting the capabilities of the
browser that made a request for the page.

Now, to answer your question. Here is the javascript used to reload a iframe:

<iframe name='content'></iframe>
<script language='javascript'>
parent.frames.item('content').location.href = 'mypage.aspx';
</script>

"Ben" wrote:
could you please supply the code that can be called from the C# method that
will refresh another frame called "Main"?

thanks. I am not familiar with javascripting.

ben

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

"Ben" <ben_1_ AT hotmail DOT com> wrote in message
news:84**********************************@microsof t.com...
> Hello
>
> 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).
>
> is this possible?

you can refresh any of the frames using javascript, you can either Refresh
the frame, submit the form , or call a method to a control (like button
click ) these actions will refresh the form
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

May 17 '06 #11

P: n/a
Ben
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

May 17 '06 #12

P: n/a
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

May 17 '06 #13

P: n/a
Ben
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

May 17 '06 #14

P: n/a
Seems that you don't have event handler binding to you btnTest

Check InitializeComponent() function for the lines below
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);

this line creates eventHandler and binds btnTest_Click function as handler
of you button.
And exactly this function is called by (Page.FindControl("btnTest") as
Button).Click.Invoke(this, new EventArgs());
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

--
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
May 17 '06 #15

P: n/a
Ben
Hellow again

Yup. the event handler has been initialized for the btnTest.

I feel like this is becoming a lost cause...

"Michael Nemtsev" wrote:
Seems that you don't have event handler binding to you btnTest

Check InitializeComponent() function for the lines below
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);

this line creates eventHandler and binds btnTest_Click function as handler
of you button.
And exactly this function is called by (Page.FindControl("btnTest") as
Button).Click.Invoke(this, new EventArgs());
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
>
>

--
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

May 17 '06 #16

P: n/a
HI,

"Ben" <ben_1_ AT hotmail DOT com> wrote in message
news:04**********************************@microsof t.com...
Nate
thank you for your reply

are you telling me there is no way that i can then refresh a specific
frame
AFTER the server side code is run? that is what i require...ie a way of
calling the javascript you provided.


Yes, but not by the server but by the client. in the server you insert code
that will be executed in the client to force a refresh:

like
in aspx page:
<body runat="server" id=Thebody>

in the .cs:
protected HtmlgenericControl theBody;

theBody.Attributes.Add("onLoad","the code to refresh the frame OR a method
to call that does it");

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
May 17 '06 #17

P: n/a
Post you working code demonstrating the problem.
Hellow again
Yup. the event handler has been initialized for the btnTest.
I feel like this is becoming a lost cause...
"Michael Nemtsev" wrote:
Seems that you don't have event handler binding to you btnTest
Check InitializeComponent() function for the lines below
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);

this line creates eventHandler and binds btnTest_Click function as handler
of you button.
And exactly this function is called by (Page.FindControl("btnTest") as
Button).Click.Invoke(this, new EventArgs());
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
> >
> >


--
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

May 17 '06 #18

P: n/a
Ben
Sorry it took so long for the reply, but here is the code:

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
this.btnTest.Attributes.Add("onclick", "if(confirm('Are you sure you
want to update the
grouping?')){javascript:parent.menu.location.reloa d(true);}else{return
false}");
(Page.FindControl("btnTest") as Button).Click.Invoke(this, new EventArgs());

}
}
May 18 '06 #19

P: n/a
heh,

your onClick code (confirm message) is javascript one, and you are trying to
call client code from the server one by Click.Invoke and that's why you got
such error that you post in previous messages - you server-side environment
doesn't see the handler for you button.

this.btnTest.Attributes.Add doesn't create handler for you server control,
it just set button's property for the client, nothing else.

In this situation you need to choose the side you are trying to keep either
client or server, but not mixing both.
Sorry it took so long for the reply, but here is the code:

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
this.btnTest.Attributes.Add("onclick", "if(confirm('Are you sure you
want to update the
grouping?')){javascript:parent.menu.location.reloa d(true);}else{return
false}");
(Page.FindControl("btnTest") as Button).Click.Invoke(this, new EventArgs());

}
}


--
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
May 18 '06 #20

P: n/a
Ben
so how would i remedy this?

do i need to then fillout the code the btnTest_click () event/handler in the
'code behind' secton? and then it will work? because I had that method
already there, just nothing inside it. Or, do I need to write a javascript
method for the button click inside the HTML file?

Sorry for all the trouble, but as i said, im new to the world of web
applications.

thanks.

"Michael Nemtsev" wrote:
heh,

your onClick code (confirm message) is javascript one, and you are trying to
call client code from the server one by Click.Invoke and that's why you got
such error that you post in previous messages - you server-side environment
doesn't see the handler for you button.

this.btnTest.Attributes.Add doesn't create handler for you server control,
it just set button's property for the client, nothing else.

In this situation you need to choose the side you are trying to keep either
client or server, but not mixing both.
Sorry it took so long for the reply, but here is the code:

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
this.btnTest.Attributes.Add("onclick", "if(confirm('Are you sure you
want to update the
grouping?')){javascript:parent.menu.location.reloa d(true);}else{return
false}");
(Page.FindControl("btnTest") as Button).Click.Invoke(this, new EventArgs());

}
}


--
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

May 19 '06 #21

P: n/a
Just use javascript for this button
so how would i remedy this?

do i need to then fillout the code the btnTest_click () event/handler in the
'code behind' secton? and then it will work? because I had that method
already there, just nothing inside it. Or, do I need to write a javascript
method for the button click inside the HTML file?

Sorry for all the trouble, but as i said, im new to the world of web
applications.

thanks.

"Michael Nemtsev" wrote:
heh,

your onClick code (confirm message) is javascript one, and you are trying to
call client code from the server one by Click.Invoke and that's why you got
such error that you post in previous messages - you server-side environment
doesn't see the handler for you button.

this.btnTest.Attributes.Add doesn't create handler for you server control,
it just set button's property for the client, nothing else.

In this situation you need to choose the side you are trying to keep either
client or server, but not mixing both.
Sorry it took so long for the reply, but here is the code:

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
this.btnTest.Attributes.Add("onclick", "if(confirm('Are you sure you
want to update the
grouping?')){javascript:parent.menu.location.reloa d(true);}else{return
false}");
(Page.FindControl("btnTest") as Button).Click.Invoke(this, new EventArgs());

}
}


--
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

May 19 '06 #22

This discussion thread is closed

Replies have been disabled for this discussion.