473,503 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem in execution of Client script and server method while a single click.

10 New Member
hi all. in my shopping cart project , i tested with two buttons, one for execution of client click and another for exection server method. these two buttons are as follows..
<input id="addbutton" type="button" value="Add Products" onclick='addToBasket(<%#DataBinder.Eval(Container. DataItem, "ProductNo")%>)' />
//this button used for execution for javascript method...
<asp:Button ID="Button1" runat="server" Commandname='<%#DataBinder.Eval(Container.DataItem , "ProductNo") %> ' OnCommand="FilterData" Text="Add to Cart" /></br>
// this button used for execution of serverside method..


Now i need to combine both button functons in a single button..(ie) when i click the button it execute both javascript function and also server side code..
is it possible.. any one know how to do this..
i am waiting for your reply..

thank you...
Dec 18 '07 #1
4 1377
Murdz
34 New Member
It is definitely possible:

Expand|Select|Wrap|Line Numbers
  1. <asp:Button ID="btnDo" OnClientClick="return addToBasket()" CommandName="" OnClick="btnDo_Click" runat="server" />
  2.  
This will call the javascript method addToBasket, and assuming it doesn't return false, it will then do the server postback and call btnDo_Click
Dec 18 '07 #2
Shanthini Ganesh
10 New Member
It is definitely possible:

Expand|Select|Wrap|Line Numbers
  1. <asp:Button ID="btnDo" OnClientClick="return addToBasket()" CommandName="" OnClick="btnDo_Click" runat="server" />
  2.  
This will call the javascript method addToBasket, and assuming it doesn't return false, it will then do the server postback and call btnDo_Click
Hi. Thank u for ur Reply..
I tried ur code..
<asp:Button ID="Button1" Text="add to cart" OnClientClick='return addToBasket(<%#DataBinder.Eval(Container.DataItem, "ProductNo")%>)' OnCommand="FilterData" CommandName='<%#DataBinder.Eval(Container.DataItem , "ProductNo")%>' runat="server" />
But it didnt call clientside script (javascript function add to basket)..
Thanks again
Dec 18 '07 #3
sudhashekhar30
44 New Member
hi.
just try this way.
in aspx.cs page add
buttonserver.attributes.add("onclick","javascriptf unction()")

inline code
javascript function()
{
if()
{ coding
return true; //go to server
}
else
{ coding
return false; // don't go to server
}
}
Dec 18 '07 #4
Murdz
34 New Member
The code is valid as I've run it myself. View the HTML output of the aspx page and ensure the button has the onclick attribute added and the js function name is valid, etc.
Dec 19 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
2621
by: Bartosz Wegrzyn | last post by:
I need help with sessions. I createt set of web site for nav with authorization. first I go into main.php which looks like this: <?php //common functions include_once '../login/common.php';...
5
6288
by: Boris Nikolaevich | last post by:
This is backwards of what I usually want--normally if you have a long-running ASP script, it's a good idea to check to see whether the client is still connected so you can cancel execution. ...
5
3030
by: Alastair Anderson | last post by:
I have created a very simple form with which I would like to update a single value in a single row of a database as a proof of concept. The relevant parts of the form are a DBWebTextBox (which...
5
3733
by: Nedu N | last post by:
Hi All, I am facing a typical problem in my .NET application with the pop-up script messages. The thing is that its working fine when i run on my development machine but not running in expected...
5
2132
by: ElanKathir | last post by:
Hi ! I wrote one code for Send the E-mail, But that code have some problem , So please help me Here i paste my code and Error: Error: Server Error in '/Elan_Sample' Application. ...
6
3314
by: Guadala Harry | last post by:
I have some client-side JavaScript that, among other things, calculates the value of a variable (myVar). On the server I have a stored procedure that needs to somehow receive as an input parameter...
9
4894
by: Rea | last post by:
Hi eb I set some 'Stop' statements and also visual breakpoints in asp code (vbscript). I am doing that in Microsoft Script debugger. Than I refresh the original page and expect execution to halt...
9
5742
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
5
2846
by: Guillermo Antonio Amaral Bastidas | last post by:
Hi everybody, I have a quick and probably dumb question, keep in mind I just dumped my old love FastCGI + Perl for it's younger hotter friend PHP5. If the user calls a time consuming script...
0
7093
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...
0
7287
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
7349
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
7467
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
5594
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
4688
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...
0
3177
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...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
399
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...

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.