473,386 Members | 1,943 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,386 software developers and data experts.

Is there a way to submit a button automatically from C# behind?

Hello,

I have the following 'Add to Cart' button on my ASP.NET C# website that receives some values I previously saved in 2 session variables and then passes those values to an external script (a shopping cart) once the following button is clicked:
Expand|Select|Wrap|Line Numbers
  1. <input id="product_name" value='<%Response.Write(Session["Selected_add_to_cart_name"]);%>' class="product-title" type="hidden">
  2. <input id="product_price" value='<%Response.Write(Session["Selected_add_to_cart_price"]);%>' class="product-price" type="hidden" >
  3. <div title="Add to cart" role="button" tabindex="0" class="add-button" type="hidden">

The following is the external script that displays the shopping cart on my website:
Expand|Select|Wrap|Line Numbers
  1. <script id='cart-script' type='text/javascript' src='https://xx integration='jscart-wizard' post-cart-to-sandbox='false' currency='GBP'></script>

My question is How can I auto-submit the above button from c# behind?

I placed my own 'Add to Cart' ASP button that first executes some stuff I want to do with my database before I actually send the information to the external shopping cart. Therefore I would like to execute the above button and somehow .Click() it after I finish with my stuff first..

How can I do that?


Thank you in advance
Feb 3 '09 #1
3 5082
Frinavale
9,735 Expert Mod 8TB
This could be a bit tricky.
You could try adding a JavaScript function that calls the shopping card script during the window.onload event. The function would have to check conditions set during your server side code...


So basically, have your button submit to the server and set a Hidden Field value which would indicate that the shopping card script should be executed. Check the hidden field in the JavaScript function which is executed during the window.onload event....if the hidden field indicates that processing should be executed then call the shopping card script, otherwise don't call it.
Feb 3 '09 #2
Can you please point out what I would need to write to send the values of my 2 Session variables to the external script/shopping cart once the Argument (in my C#) is true?

If I simply call the external script:
<script id='cart-script' type='text/javascript' src='https://xx integration='jscart-wizard' post-cart-to-sandbox='false' currency='GBP'></script>

Then All that will happen will be that the external shopping cart will appear on my page (a small square lets the users know what they have in their basket)..

where as I need to find out how I can execute the following button from C# along with the 2 Session Variables that I set as the button's values:

<input id="product_name" value='<%Response.Write(Session["Selected_add_to_cart_name"]);%>' class="product-title" type="hidden">
<input id="product_price" value='<%Response.Write(Session["Selected_add_to_cart_price"]);%>' class="product-price" type="hidden" >
<div title="Add to cart" role="button" tabindex="0" class="add-button" type="hidden">



Thanks again
Feb 3 '09 #3
found the solution here:

http://www.developerfusion.com/forum/thread/53020/
Feb 4 '09 #4

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

Similar topics

0
by: Niks | last post by:
Hi, I am creating a simple .aspx page to add some fields with validation. I have used different .NET validations like REquiredFieldValidator, RegularExpressionValidator and showed the summary...
3
by: Arun K | last post by:
Hi, I am creating a simple .aspx page to add some fields with validation. I have used different .NET validations like REquiredFieldValidator, RegularExpressionValidator and showed the summary...
3
by: Russell | last post by:
I have a web page that i am using an image button as my submit button. The code behind the button works, but when I click enter on the web page, nothing happens. Can anybody tell me how to get my...
10
by: Perry van Kuppeveld | last post by:
Hi, I have a problem with formatting a table including text fields wich can contain up to 255 chars. I need a table with 3 columns: - First column 50 % over the with a rowspan of the total...
6
by: milkyway | last post by:
Hello there, I have the following code (written in Javascript) for posting of a form on the client side: .... var f2 = document.forms; f2.method = "post"; f2.submit();
16
by: NathyZif | last post by:
I know I know, why would I want to submit the form from server-side code, if the only way to get to the server-side code was BY submitting the form. But that's just it, when the code-behind...
2
by: Milkstr | last post by:
I have a page with a form, a couple of hidden fields and a submit button, the information in the hidden fields i want to submit automatically without clicking the submit button, is there a way of...
10
by: The Natural Philosopher | last post by:
I am coding up a bit of javascript stuff, and have managed to stumble my way through most of what I want.. But this one has got me stumped. I call submit() and get a javascript error 'Submit...
3
by: Daniel | last post by:
Hi all, I am using .NET 1.1. I have a form with a cancel button, something like this: <form method="post"....> <input type="submit" value="Submit"> <input type="submit" value="Cancel"...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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...

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.