473,385 Members | 1,409 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,385 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 6519
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.