tags:

views:

62

answers:

3
+1  Q: 

Multiple Add in IE

In asp.net using C#.net in back end, after click on Add I am adding the stock and closing the window (which I have opened using window.open) using Javascript. Although this works well in other browsers, [in MSIE] if I keep clicking on the Add button it adds multiple stock entries. This is really weird behaviour. Any idea on how I can overcome this.

AddStock(sessionID, stock,perms);
string script = "window.parent.closeIFrame();";
ClientScript.RegisterStartupScript(this.GetType(), "close", script, true);

closeIFrame() is defined on the parent page.
A: 

If you mean clicking Add several times right after eachother, you will have to do server-side validation to ensure that 'AddStock' won't be called several times. This is default behaviour, as you can do multiple POST's to the backend, and the request won't get killed when doing another one.

edit You might want to something like this,

if(((TimeSpan)(DateTime.Now - (Session["LastAddedStock"] ?? DateTime.Min)).TotalSeconds < 15)
    //don't proceed, as the last addStock was less than 15 secs. ago
else
    //Do Add Stock
    Session["LastAddedStock"] = DateTime.Now;
Jan Jongboom
A: 

As I can see AddStock(...) procedure is in the child form. So, why you need to call parent function to close the child form, when you can just call javascript in the same child form: close()?

ZokiManas
+1  A: 

I got a way to this we can disable the button on click this is the link to a beautiful article for this

Pranali Desai
People without javascript enabled can still click several times.
Jan Jongboom
ya but we are making sure that all the Users have Javascript enabled since this is the product that is to be Used by IT companies.
Pranali Desai