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

Web User Control - fire function from client side

Ant
I'm building a Web user control that has several public functions. Can
I fire them from the client side? for example Javascript and an HTML
button
Nov 18 '05 #1
3 2065
yes

you just need to invoke a postback from javascript - you basically simulate
a click on a hidden button or something (google for details on how to do
this).

"Ant" <am*****@bigfoot.com> wrote in message
news:5b**************************@posting.google.c om...
I'm building a Web user control that has several public functions. Can
I fire them from the client side? for example Javascript and an HTML
button

Nov 18 '05 #2
Ant
Thank you Andy.

I'm not that good with Javascript and I hope that I can get some help
here, this is what I have:

I created a Web User Control with the following:
Button1 (just in case I can not call the function directly)
Button2 (just in case I can not call the function directly)
Label1 (to display the status of my connection)
Connect (Function called when you 'click' on Button1)
Disconnect (Function called when you 'click' on Button2)

I placed my control in a ASPX page, with two HTML buttons:
<cc1:im_cicwebcontrol id="IM_CICWebControl1" ...
Button1 (calls a Javascript funtion (Connect))
Button2 (Calls a Javascript function (Disconnect))

When I run the ASPX page and 'view source' the page, I only see my
HTML buttons and my control items but with a different name:
for Button1 --> IM_CICWebControl1_Button1
for Button2 --> IM_CICWebControl1_Button2
for Label1 --> IM_CICWebControl1_Label1

I tried to call it like this in my javascript:
var myObj = document.Form1;
alert (myObj.id);
myObj.IM_CICWebControl1_Button1; (does not work)
myObj.IM_CICWebControl1_Button1.Click; (does not work)
myObj.IM_CICWebControl1_Button1.Button1_Click; (does not work)

It does not work and I can not call also the functions...
Any Ideas???

Thanks
Ant
"Andy Fish" <aj****@blueyonder.co.uk> wrote in message news:<ub**************@TK2MSFTNGP15.phx.gbl>...
yes

you just need to invoke a postback from javascript - you basically simulate
a click on a hidden button or something (google for details on how to do
this).

"Ant" <am*****@bigfoot.com> wrote in message
news:5b**************************@posting.google.c om...
I'm building a Web user control that has several public functions. Can
I fire them from the client side? for example Javascript and an HTML
button

Nov 18 '05 #3
I'm a bit confused about whether the Connect function is to run on the
client (i.e. javascript) or on the server (i.e. inside the form control). I
assume you mean on the server.

if it's on the server, you need to invoke the __doPostBack() function from
your javascript. the Page.GetPostBackEventReference function (on the server)
will generate the right parameters for the call.

Also, I think you are trying to solve 2 problems at once here: doing a
postback from javascript and integrating it with a user control. I would
suggest you get the javascript working without a user control before adding
that into the mix

HTH

Andy

"Ant" <am*****@bigfoot.com> wrote in message
news:5b**************************@posting.google.c om...
Thank you Andy.

I'm not that good with Javascript and I hope that I can get some help
here, this is what I have:

I created a Web User Control with the following:
Button1 (just in case I can not call the function directly)
Button2 (just in case I can not call the function directly)
Label1 (to display the status of my connection)
Connect (Function called when you 'click' on Button1)
Disconnect (Function called when you 'click' on Button2)

I placed my control in a ASPX page, with two HTML buttons:
<cc1:im_cicwebcontrol id="IM_CICWebControl1" ...
Button1 (calls a Javascript funtion (Connect))
Button2 (Calls a Javascript function (Disconnect))

When I run the ASPX page and 'view source' the page, I only see my
HTML buttons and my control items but with a different name:
for Button1 --> IM_CICWebControl1_Button1
for Button2 --> IM_CICWebControl1_Button2
for Label1 --> IM_CICWebControl1_Label1

I tried to call it like this in my javascript:
var myObj = document.Form1;
alert (myObj.id);
myObj.IM_CICWebControl1_Button1; (does not work)
myObj.IM_CICWebControl1_Button1.Click; (does not work)
myObj.IM_CICWebControl1_Button1.Button1_Click; (does not work)

It does not work and I can not call also the functions...
Any Ideas???

Thanks
Ant
"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:<ub**************@TK2MSFTNGP15.phx.gbl>...
yes

you just need to invoke a postback from javascript - you basically
simulate
a click on a hidden button or something (google for details on how to do
this).

"Ant" <am*****@bigfoot.com> wrote in message
news:5b**************************@posting.google.c om...
> I'm building a Web user control that has several public functions. Can
> I fire them from the client side? for example Javascript and an HTML
> button

Nov 18 '05 #4

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

Similar topics

0
by: Matt Low via .NET 247 | last post by:
Hello - I'm trying to create a simple javascript function thatcan read the attribute value of a custom server control createdusing C#. I've created a custom textbox control (MyTextBox), which...
1
by: Hal | last post by:
My most sincere gratitude to anyone who can help me work around this! I have work that needs to be done in javascript on the client whenever a page is unloaded. To this end, I subscribe to...
1
by: Dan Brussee | last post by:
I know, of course that client side stuff cant call server code directly. What I am doing is putting in a basic LeftHand menu bar using a user control that contains a datagrid composed of linkbutton...
6
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I...
1
by: roni | last post by:
hi. i have webform with 4 panel that i switch then in wizard style ( asp 1.1) . i want to know if i can hide/show the asp panel control IN THE CLIENT SIDE ? meaning, show panel 1 . user enter...
2
by: milkyway | last post by:
Hello, I am using Visual Studio 2005 now. Is there an example out there where one can see a Microsoft Datagrid control being modified on the client side - specifically by javascript? I wanted to...
3
by: David Davis | last post by:
I cannot get a web user control to validation client-side using a required field validator. It only validates server side. I have a web user control in .net 2.0. I have a single text box on it....
0
by: alrotem | last post by:
Hi, I'm using an <asp:TreeViewcontrol on my page. Combining the TreeView's OnTreeNodePopulate server-side event handler, and the PopulateOnDemand set to "true" on each node, I get client-based...
5
by: Kursat | last post by:
Hi, I want to add new collapsable panel items using java script at client side. Is this possible to create Ajax components like collapsable panel without server round trip? Thanks in advance.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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,...
0
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...

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.