473,396 Members | 1,917 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,396 software developers and data experts.

simulate button click in C#

Max
Hi

Is it possible to somehow simulate button click in C#

Thanks
Nov 18 '05 #1
7 6520
Hi, Max,

Can you explain what are you trying to do? You can call the method that
handles the Click event at any point supposing that you have instance of the
class in which the method is member:

if(someCondition)
Button1_Click(null, null);

Greetings
Martin
"Max" <an*******@discussions.microsoft.com> wrote in message
news:E7**********************************@microsof t.com...
Hi!

Is it possible to somehow simulate button click in C#?

Thanks

Nov 18 '05 #2
Max
Thanks Martin

What I am trying to do i

When user clicks Button1 then some attributes are added to Button2 which then should invoke VB Script function
I need all this done by just clicking Button1. I have this webform where user can search adequate conference rooms for the particular meeting. When user completes filling criterias in form, the code I wrote searches adequate conferense roomss' names in SQL Server and then those conference rooms and criterias are passed to my VB Script as parameters. The VB script then adds adequate conference rooms as resources in Outlook. So I need Button1 to Add script attributes to Button2 (Because I am using parameters in VB script) and then Button2 should run VB script. I tried to call Button2's Click method (Button2_Click(null, null)), but id did not run the VB script, so user needs to actually click Button2 also, which is bad. Can I somehow work around this

Max
Nov 18 '05 #3
Hi, Max,

You can add client-side script to the page that will call Button2.Click() or
call directly the VBScript function that handles the click. Use the
RegisterClientScriptBlock or RegisterStartupScript methods on the Page
class.

The only way to call a client-side function is to add client-side code to do
this.

Hope this helps
Martin
"Max" <an*******@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
Thanks Martin,

What I am trying to do is

When user clicks Button1 then some attributes are added to Button2 which then should invoke VB Script function. I need all this done by just clicking Button1. I have this webform where user can search adequate conference rooms for the particular meeting. When
user completes filling criterias in form, the code I wrote searches adequate
conferense roomss' names in SQL Server and then those conference rooms and
criterias are passed to my VB Script as parameters. The VB script then adds
adequate conference rooms as resources in Outlook. So I need Button1 to Add
script attributes to Button2 (Because I am using parameters in VB script)
and then Button2 should run VB script. I tried to call Button2's Click
method (Button2_Click(null, null)), but id did not run the VB script, so
user needs to actually click Button2 also, which is bad. Can I somehow work
around this?
Max

Nov 18 '05 #4
Max
Please, could you tell me, how can I call directly the vb script after I registered it with RegisterClientScriptBlock? Sorry for asking so simple questions, I started developing with ASP.NET just few weeks ago.

thanks

Max
Nov 18 '05 #5
Max
Please, could you tell me, how can I call directly the vb script after I registered it with RegisterClientScriptBlock? Sorry for asking so simple questions, I started developing with ASP.NET just few weeks ago.

thanks

Max
Nov 18 '05 #6
The following will call the function immediately after the page is loaded:

string script = @"<SCRIPT FOR=window EVENT=onload LANGUAGE="vbscript">" +
Environment.NewLine;
script += @" ' Do something, i.e. call the Button2_Click function" +
Environment.NewLine;
script += string.Format(@"Button2_Click {0}, {2}{3}", param1, param2,
Environment.NewLine);
script += @"</SCRIPT>";
RegisterClientScriptBlock(script, "Call Button2_Click");

Hope this helps
Martin
"Max" <an*******@discussions.microsoft.com> wrote in message
news:2A**********************************@microsof t.com...
Please, could you tell me, how can I call directly the vb script after I registered it with RegisterClientScriptBlock? Sorry for asking so simple
questions, I started developing with ASP.NET just few weeks ago.
thanks,

Max

Nov 18 '05 #7
The following will call the function immediately after the page is loaded:

string script = @"<SCRIPT FOR=window EVENT=onload LANGUAGE="vbscript">" +
Environment.NewLine;
script += @" ' Do something, i.e. call the Button2_Click function" +
Environment.NewLine;
script += string.Format(@"Button2_Click {0}, {2}{3}", param1, param2,
Environment.NewLine);
script += @"</SCRIPT>";
RegisterClientScriptBlock(script, "Call Button2_Click");

Hope this helps
Martin
"Max" <an*******@discussions.microsoft.com> wrote in message
news:2A**********************************@microsof t.com...
Please, could you tell me, how can I call directly the vb script after I registered it with RegisterClientScriptBlock? Sorry for asking so simple
questions, I started developing with ASP.NET just few weeks ago.
thanks,

Max

Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: johnny | last post by:
On a form I would like to simulate a button click when the Enter is pressed. My form is setup and it works if the delegate for the key pressed on the form calls the delegate for the button pressed....
5
by: Max | last post by:
Hi Is it possible to somehow simulate button click in C# Thanks
2
by: Eli | last post by:
HI! I made some quiz using one HTML form (few question with few radio-button each like potential answers) that have one Submit button. I would like to simulate click on this button (e.g. named...
3
by: John Dalberg | last post by:
I have an app that keeps popping up a windows with a 'Yes' or 'OK' button on it. I am trying to write a little app that automates hitting the enter key so I don't have to do it myself. I used...
4
by: flplini | last post by:
I want to ask how to use C++ to simulate the mouse control? ex:Let the mouse double-click the left key functions,thanks!
18
by: eliss.carmine | last post by:
Is it possible to simulate a mouse click in the window I made (it's a Form), but not give it focus? I tried using WinAPI's mouseevent and SendMessage of WM_LBUTTONDOWN/WM_LBUTTONUP as suggested...
9
by: =?Utf-8?B?TWFyYyBXb29sZnNvbg==?= | last post by:
I have what seems to be a relatively simple problem when attempting to simulate a postback in ASP.NET from JavaScript. My scenario is (and please don't ask me why) that I have an HTML <a>nchor...
1
by: Hooyoo | last post by:
Hi, everyone. I want "steal" data from a web page :), but their data are stored in a data grid, and more than 1,000 pages in the data grid. Everytime I need click "Next Page" to view next page...
5
by: nuhfeken | last post by:
We have a C# winform that uses the MVP design pattern for the user interface. For reasons I'd rather not explain we need to simulate a right mouse click on a specific control to deactivate the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.