473,811 Members | 4,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simulate button click in C#

Max
Hi

Is it possible to somehow simulate button click in C#

Thanks
Nov 18 '05 #1
7 6541
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(someConditio n)
Button1_Click(n ull, null);

Greetings
Martin
"Max" <an*******@disc ussions.microso ft.com> wrote in message
news:E7******** *************** ***********@mic rosoft.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
RegisterClientS criptBlock or RegisterStartup Script 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*******@disc ussions.microso ft.com> wrote in message
news:8A******** *************** ***********@mic rosoft.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 RegisterClientS criptBlock? 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 RegisterClientS criptBlock? 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="vbscr ipt">" +
Environment.New Line;
script += @" ' Do something, i.e. call the Button2_Click function" +
Environment.New Line;
script += string.Format(@ "Button2_Cl ick {0}, {2}{3}", param1, param2,
Environment.New Line);
script += @"</SCRIPT>";
RegisterClientS criptBlock(scri pt, "Call Button2_Click") ;

Hope this helps
Martin
"Max" <an*******@disc ussions.microso ft.com> wrote in message
news:2A******** *************** ***********@mic rosoft.com...
Please, could you tell me, how can I call directly the vb script after I registered it with RegisterClientS criptBlock? 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="vbscr ipt">" +
Environment.New Line;
script += @" ' Do something, i.e. call the Button2_Click function" +
Environment.New Line;
script += string.Format(@ "Button2_Cl ick {0}, {2}{3}", param1, param2,
Environment.New Line);
script += @"</SCRIPT>";
RegisterClientS criptBlock(scri pt, "Call Button2_Click") ;

Hope this helps
Martin
"Max" <an*******@disc ussions.microso ft.com> wrote in message
news:2A******** *************** ***********@mic rosoft.com...
Please, could you tell me, how can I call directly the vb script after I registered it with RegisterClientS criptBlock? 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
5176
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. But can we simulate a button click instead? This way if later the delegate is changed for the button, we don't forget to do the changes on other events?
5
818
by: Max | last post by:
Hi Is it possible to somehow simulate button click in C# Thanks
2
29498
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 "Finish") after some time, 10 minute or so, which be equal like click on submit button and terminate quiz (open another page or so). I tried to solve it by JavaScript but won't, always error, like can't detect button like object. What to do? Listing...
3
29918
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 the FindWindow method to get a handle of the window and then issued: SendMessage(hwnd, 273, 0, IntPtr.Zero) to send an ENTER key to it but it didn't work. If I need to get the handle of the 'OK' button, how do I do it? (How do you
4
7521
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
22123
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 by the folks in #winapi on EFnet, but I think those require the window to have focus. Either that, or I'm doing something else wrong. The click actually seems to work once, and then stops working... I have no idea what is the problem actually....
9
3826
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 which is generated dynamically using the DOM, and when clicked should force an <asp:Buttonto do a postback so that some server-side processing can be done. The relevant JavaScript is below: function GetAnchor() { theAnchor =...
1
1909
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 data. Would you please share me a free application to simulate this button click operation? I hope this application also can save the page content after a button click. If you can tell me how to DIY such a simulator, I will appreciate you more...
5
30705
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 control. I found code that almost does what we need. private static extern void mouse_event( UInt32 dwFlags, // motion and click options UInt32 dx, // horizontal position or change UInt32 dy, //...
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10397
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10413
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10138
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7674
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5565
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4353
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3879
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.