Search:
Namespaces
Discussions
.NET v1.1
Feedback
Server side button calling JavaScript function
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngclient' list
.
Greg Quinn
I have the following web control...
<asp:button id = "shareBut" Text = "Sharing..." onClick =
"JavaScript:Initialize();" runat = "server" />
Since it is a server control, obviously the JavaScript is not recognised as
a .NET function. Now besided writing my own function that response.writes
the Javascript, is there any quicker way to call a JavaScript function
directly from a web control?
Greg
Reply to this message...
Andy Smith
if you want to attach clientside handlers to the final rendering of the =
control, then you can usually add them to the attributes collection of =
the control like thus:
[C#]
myControl.Attributes["onclick"] =3D "myJavaScriptFunction();";
there is not, however, any way to add this specific handler in the tag =
of the control, because it would interfere with the serverside onclick =
attribute.
__
Andy Smith
Keyboard Jockey #3a7-2.78.1
[Original message clipped]
Reply to this message...
babu n
(Type your message here)
--------------------------------
From: babu n
Reply to this message...
Greg Quinn
Okay thanks, but the problem with that approach then is that the form the
button resides in still refreshes when the button is clicked.
I need a button that when clicked only calls my Javascript, it mustn't
refresh the form again. But I also need it to be running server side so I
can set it to visible or invisible based on certain conditions.
Greg
-----Original Message-----
From: Andy Smith [mailto:
Click here to reveal e-mail address
]
Sent: Monday, August 12, 2002 8:12 AM
To: aspngclient
Subject: [aspngclient] RE: Server side button calling JavaScript
function
if you want to attach clientside handlers to the final rendering of the
control, then you can usually add them to the attributes collection of the
control like thus:
[C#]
myControl.Attributes["onclick"] = "myJavaScriptFunction();";
there is not, however, any way to add this specific handler in the tag of
the control, because it would interfere with the serverside onclick
attribute.
__
Andy Smith
Keyboard Jockey #3a7-2.78.1
[Original message clipped]
| [aspngclient] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.aspfriends.com/aspfriends/aspngclient.asp
= JOIN/QUIT
Reply to this message...
Andy Smith
ok, add a "return false;" to the end of the javascript.
myControl.Attributes["onclick"] =3D "myJavaScriptFunction();return =
false;";
that will cancel the event, and the control will not cause a postback.
__
Andy Smith
Keyboard Jockey #3a7-2.78.1
[Original message clipped]
Reply to this message...
babu n
(Type your message here)
--------------------------------
From: babu n
Hai,
I saw your reply. It was nice.
i have that 2 questions
1. What does 3d means here (myControl.Attributes["onclick"] =3D "myJavaScriptFunction();return =false;";)
2. how to get the return value from a javascript function in c# .
Please reply me.
Reply to this message...
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com