473,325 Members | 2,671 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,325 software developers and data experts.

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

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
21 8100
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve | last post by:
Hi, Is it possible to make hitting the enter key in an ASP textbox run the code behind an ASP button on a form? I have a search page which users tend to type in the query then just hit enter...
0
by: Quentin Huo | last post by:
Hi: In my page, there is a user control and there are some actions in the user control like "save", "delete",...which are the control <asp:button onclick="btSave_Click" ......>. And there are...
0
by: maitrepoy | last post by:
hello I have to create a small addin which works on Powerpoint, Word, Outlook, and Excel on Office 2000, XP, and 2003. This addin consists in adding 2 new Buttons in the "File" Menu of office....
2
by: Serious_Practitioner | last post by:
Good day, and thank you in advance for any assistance. I'm having trouble with something that I'm trying for the first time. Using Access 2000 - I want to run a function either on the click of a...
7
by: the_grove_man | last post by:
How do I invoke a "Right-Click" Programmtically? John
12
by: Thammarat charoenchai. | last post by:
Hi, I'm try to learn vb.net. in delphi have .click method for click button by coding. Can I do that with vb.net Thank you very much.
2
by: wpollans | last post by:
Hello, I need to able to write JS that will click on a link with the middle mouse button - so that the link target will open in a new window or tab - using firefox. Or is there a better (more...
5
by: laziers | last post by:
Hi, anyone know how to write a single-cilick button? I use this: <asp:button id="ButtonAdd" runat="server" text="Anuluj" onclick="Click_ButtonAdd" /> if ( !isPostBack){...
3
Curtis Rutland
by: Curtis Rutland | last post by:
OK, I have a question. I have a problem. I'm trying to catch all KeyDown events on a button, but the problem is when I press the "Enter" key, the button's "Click" event is triggered, not the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.