| | |
Pass a variable value into a Button value c#
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2008
Posts: 9
Reputation:
Solved Threads: 0
Hello..
I dont know where to start with my question.
I have a website that displays products (products retrieved from a database).
I use Datalist to display these products and this Datalist is linked to a Command in the C# code.
Within this datalist I have <itemtemplate> </itemtemplate> tags
Between the <itemtemplate> </itemtemplate> tags I have a Google 'Add to Cart' button as follows:
But what I want to do is replace the 22.00 input value with a Session Variable in my C# code. The session variable 'Session["Session_price"] will need to contain the price of the related product. So when the user clicks on the GOOGLE button that appears repeatetely because of the <itemtemplate> then I want to exececute a Command that will contain the code to connect to my database, retrieve the price of the related product and pass the price to the Google Button.
I have already a Command Argument in place for when the user clicks on a 'More Info' link that I also placed between the <itemtemplate> tags. When the user clicks on the 'More info' link it calls up a Command that contains a code that retrieves the description of the chosen product by filtering the Product Code.
I hope I make sense.
To summarize I want to modify the Google button (that is repeated due to the itemtemplate) as such so it gets the value of the price of a related product that also appears along with the Google Button in the <itemtemplate>.
Thank you in advance. Your help will help me save thousands of times.
I dont know where to start with my question.
I have a website that displays products (products retrieved from a database).
I use Datalist to display these products and this Datalist is linked to a Command in the C# code.
Within this datalist I have <itemtemplate> </itemtemplate> tags
Between the <itemtemplate> </itemtemplate> tags I have a Google 'Add to Cart' button as follows:
HTML Syntax (Toggle Plain Text)
<div class="product"><input value="test" class="product-title" type="hidden"><input value="22.00" class="product-price" type="hidden"><div title="Add to cart" role="button" tabindex="0" class="googlecart-add-button"></div></div>
But what I want to do is replace the 22.00 input value with a Session Variable in my C# code. The session variable 'Session["Session_price"] will need to contain the price of the related product. So when the user clicks on the GOOGLE button that appears repeatetely because of the <itemtemplate> then I want to exececute a Command that will contain the code to connect to my database, retrieve the price of the related product and pass the price to the Google Button.
I have already a Command Argument in place for when the user clicks on a 'More Info' link that I also placed between the <itemtemplate> tags. When the user clicks on the 'More info' link it calls up a Command that contains a code that retrieves the description of the chosen product by filtering the Product Code.
I hope I make sense.
To summarize I want to modify the Google button (that is repeated due to the itemtemplate) as such so it gets the value of the price of a related product that also appears along with the Google Button in the <itemtemplate>.
Thank you in advance. Your help will help me save thousands of times.
Last edited by peter_budo; Jan 30th, 2009 at 1:50 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
Join Date: Dec 2008
Posts: 9
Reputation:
Solved Threads: 0
Hi again,
Ok I partly solved the problem but not completely.
I placed a <LinkButton> between my <itemtemplate> </itemtemplate> ..
This LinkButton calls a Command on the Server. This command will retrieve the product's relevant Name and Price and place these 2 values in a Session Variable.
I then pass these Session Variable values to the Google Checkout hidden <input> forms as follows:
Where Session(["Selected_add_to_cart_name"]) and Session["Selected_add_to_cart_price"])
contain the values for the name of the product and price respectively.
WHen I click on this Google button it works. It passes the correct information to my Google Cart:
However what I need now is that I Don't want to click that button manually but AUTO SUBMIT the GOOGLE button.
So within the C# server code I wish to call/submit the HTML Google Button.
Can you please let me know how to do this?
THank you
Ok I partly solved the problem but not completely.
I placed a <LinkButton> between my <itemtemplate> </itemtemplate> ..
This LinkButton calls a Command on the Server. This command will retrieve the product's relevant Name and Price and place these 2 values in a Session Variable.
I then pass these Session Variable values to the Google Checkout hidden <input> forms as follows:
html Syntax (Toggle Plain Text)
<input id="Google_cart_product_name" value='<%Response.Write(Session["Selected_add_to_cart_name"]);%> ' class="product-title" type="hidden"> <input id="Google_cart_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="googlecart-add-button" type="hidden" id="Google_click"> </div>
Where Session(["Selected_add_to_cart_name"]) and Session["Selected_add_to_cart_price"])
contain the values for the name of the product and price respectively.
WHen I click on this Google button it works. It passes the correct information to my Google Cart:
html Syntax (Toggle Plain Text)
<script id='googlecart-script' type='text/javascript' src='https://xxx' integration='jscart-wizard' post-cart-to-sandbox='false' currency='GBP'></script>
However what I need now is that I Don't want to click that button manually but AUTO SUBMIT the GOOGLE button.
So within the C# server code I wish to call/submit the HTML Google Button.
Can you please let me know how to do this?
THank you
Last edited by peter_budo; Jan 30th, 2009 at 1:51 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
![]() |
Similar Threads
- execute behind the scene mysql update/insert query just on button click (PHP)
- Create a link in a table read from a CSV file and pass a variable (PHP)
- Couldn't pass variable values to another form (C++)
- Onclick to pass a variable to a PHP script (JavaScript / DHTML / AJAX)
- Need to Pass Variables from form to form (JavaScript / DHTML / AJAX)
- How to pass a whole table to another form? (Visual Basic 4 / 5 / 6)
- How do I pass values from a called form to a calling forms variables? (C++)
- Retaining radio button value during paging (ASP)
Other Threads in the ASP.NET Forum
- Previous Thread: how to ahcieve this
- Next Thread: chat
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net bc30451 beginner bottomasp.net box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox class click compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownmenu dynamic edit embeddingactivexcontrol fileuploader findcontrol flash flv forms gridview gudi homeedition iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects order problem ratings redirect registration relationaldatabases rotatepage save search security serializesmo.table sessionvariables silverlight smartcard sql ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt webdevelopment wizard xml





