Community discussion forum

call a JAVAscript button frtom C# behind??

  • 9 months ago
    Hi, I will try to make my question as simple as possible. I have a website build in .NET (using C#). It displays a list of products that are retrieved from a DB. Within the itemtemplate of that Datalist (that displays the products) I also put a LinkButon that executes a code and this Linkbutton acts as an ADD to Cart button. The code that is being executed retrieves the product's name and price and saves these values into 2 session variables. Then I have the following HTML tag that puts the values (name, price -now saved in the Session Variables) into a Button:
    a Javascript then executes an external code (since I am using an external Shopping Cart): My problem is that I can click on the LinkButton that I created but I also have to click on the button I just pasted above.. only then will my 'name and price' values be passed to the external shopping cart. What I want to do is automatically call this Javascript from C# behind (After the 'Add to Cart' Linkbutton is executed) Please I need this urgently, any help will be very much appreciated. Thank you
    Post was edited on 30/01/2009 17:04:49 Report abuse
  • 9 months ago
    I did something similiar although the functionality is different. I put this code in the Page_Init event. This is vb code but you should be able to convert to C#. ClientScript.RegisterClientScriptBlock(Me.GetType(), "calShowBeg", "function showBegCal(){var elem = document.getElementById('" & divPopupCalBegDate.ClientID & "'); elem.style.display = 'block'; elem.style.visibility = 'visible'; elem.style.display = 'block';}", True) Then in the onClientClick event for my imagebutton I called the code this way: OnClientClick="showBegCal();return false;" Not sure if this will help... you need to modify for your usage... Good luck!

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!