Hello everyone,
I have the current problem, let's explain the context before :
I have a Modal popup extender who contains a form. There is a feature "Save and Add New", when the user click on this button the data in the form is saved in the database during postback and the page is reloaded.
I want this Modal popup to appear again on the page_load allowing the user to enter new data without clicking again on the button who show this Modal Popup.
I've tried to call it this way first :
ClientScript.RegisterStartupScript(Page.GetType(), "ModalPopup", "ShowModalPopup(""" & Me.formModalButton.ID & """);", True)
but the problem was when the function was called my Modal Popup was not existing yet on the page. Because of that the code was crashing on the
var modal = $find('myModal');
So, I found that other way and it's working almost perfectly.
ClientScript.RegisterStartupScript(Page.GetType(), "ModalPopup", "Sys.Application.add_load(function() {ShowModalPopup(""" & Me.formModalButton.ID & """)};", True)
The modal is showing up on the page load like I want, but the problem is if I click on any other button on my page the Modal Popup is also appearing again.
Example : I have another Modal Popup for deleting data, when I click on the button, both Modal are appearing, which is not cool.
Does anyone have a clue about how to fix that or a better way to do it ?
P.S. I'm not calling to Modal popup server-side because the javascript function exist in the page, so I don't want to create a copy of this function in the RegisterStartupScript.
Thx for your time.