473,769 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2080
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*****@bigfoo t.com> wrote in message
news:5b******** *************** ***@posting.goo gle.com...
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_cicwebc ontrol id="IM_CICWebCo ntrol1" ...
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_CICWebContro l1_Button1
for Button2 --> IM_CICWebContro l1_Button2
for Label1 --> IM_CICWebContro l1_Label1

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

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

Thanks
Ant
"Andy Fish" <aj****@blueyon der.co.uk> wrote in message news:<ub******* *******@TK2MSFT NGP15.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*****@bigfoo t.com> wrote in message
news:5b******** *************** ***@posting.goo gle.com...
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.GetPostBac kEventReference 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*****@bigfoo t.com> wrote in message
news:5b******** *************** ***@posting.goo gle.com...
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_cicwebc ontrol id="IM_CICWebCo ntrol1" ...
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_CICWebContro l1_Button1
for Button2 --> IM_CICWebContro l1_Button2
for Label1 --> IM_CICWebContro l1_Label1

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

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

Thanks
Ant
"Andy Fish" <aj****@blueyon der.co.uk> wrote in message
news:<ub******* *******@TK2MSFT NGP15.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*****@bigfoo t.com> wrote in message
news:5b******** *************** ***@posting.goo gle.com...
> 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
1227
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 inheritsfrom System.Web.UI.WebControls.TextBox, that has a bool propertycalled 'IsEditable'. I want a javascript routine that can getthat property value after the page has rendered. I've usedjavascript like the following to no avail: ...
1
2934
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 the unload event (client side not server side) of the <body> HTML element through javascript.
1
1729
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 controls. I am populating this either manually (one item at a time programatically) or via a DataBind to a database table. How do I link the items to server side code methods? If I had created the link buttons manually on the page, they would...
6
12289
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 would like to do this by defining a NewFunc() that is different in each (code-behind) page which is called by the standard 'New' button in the toolbar. How can I get this to work? So far I have the following (which doesnt work). When the user...
1
1522
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 data. switch to panel 2 IN CLIENT SIDE ....till panel 4
2
1161
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 add rows to the control (and remove them too). Is there a way for this to be done at all? TIA
3
8913
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. I have a public Text property defined below: <ValidationProperty("Text")> _ Partial Class MyWebUserControl Inherits System.Web.UI.UserControl
0
1519
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 functionality, with callbacks. I can clearly see that the page does not refresh, which is good, as this was my intention to begin with. I also closely inspected the client-side sources (using "Instant
5
2218
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
9423
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
10212
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
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
9995
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
9863
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...
0
8872
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
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...
1
3962
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
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.