i call bootstraps modal from code-behind,my code:
Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "initMyModal('" + timeRemain + "');", true);
in aspx page:
function initMyModal(timeRemain) {
$(".modal-body").html(timeRemain);
$('#myModal').one().modal('show');
}
My problem is when a user clicks on button back in browser and then click forward the modal appears again.
How can I prevent the display of the modal when users click on the forward button in the browser?
i solved this with using cookie
before modal is display add cookie with value when modal is showing set value in cookie
Related
I'm working on a webform using C# ASP .NET 4.5.
My modal is working great for the most part. I have a page called CustomerLookup.aspx that uses the bootstrap modal. But when I close the modal, navigate to my site's home page, and then click the back button to go back to my CustomerLookup.aspx page - the modal appears.
I don't know if it makes a difference, but these two pages use a different MasterPage.
I am using Bootstrap 3.0.0
Here is the JS code in my Site.Master
function openModal() {
$('#uxModal').modal('show');
}
Here is my code-behind on the button click event to pop up my modal:
protected void uxTestButton_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
}
I didn't get the same issue when I used an HTML button control - only with the asp:Button server control. I'm just going to get away from server controls altogether - like I'm supposed to.
I have a save button that saves the input data and a submit button that redirects to the next page. When this page first loads up, the submit button is hidden and when save is clicked, the submit button is visible and redirects to the next page when clicked. If users wants to edit the inputs, they can go back to the previous page where the inputs remain in the controls. My problem is that I want the submit button to be hidden when going to the previous page so that it forces users to save first. How do I do this?
if you use serverside conttoller
if(IsPostback)
{
btn.Visible =false;
}
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script>
$(document).ready(function () {
if ($("#TextBox1").val()) //if input has value
$("#Button1").hide(); //hide button
})
</script>
Server side code is not possible because on browser back no request is made, the page is retrieved from cache so it should be done with client code
Page_Load()
{
if(IsPostback)
{
btnSubmit.visible=false
}
}
If this is a web forms based application, try setting
btnSubmit.Visible = false in the Page_Load method
I have a parent page to display the project details, and user enter part details by uploading a template in a modal pop-up.
To open the modal popup I'm calling this function
function importfile()
{
var url="SCN_UploadPart.aspx";
var selSCE=window.showModalDialog(url,'win','help:no;status:no;scroll:no;resize:no;dialogHeight:300px;dialogWidth:490px');
return false;
}
Earlier I was using OnClinetClick method of Uplaod Button to call this method, then the project page or parent page was automatically reloading. But now I'm calling it like this.
ClientScript.RegisterStartupScript(this.GetType(), "project", "<script language='javascript'>importfile();</script>");
onclick of same Upload Button.
I font why the page does not reload now. I want the page to be reloaded as I am showing the content in the parent page after uploading the parts.
Please suggest me the way to reload the Parent page on click of close in modalpopup.
U can refer below link its show the demo
http://codedisplay.com/automaticaly-refresh-parent-window-whenever-popup-window-is-closed/
http://www.mindfiresolutions.com/Refresh-parent-page-on-closing-modal-child-windowpopup-29.php
Hope it helps u
I am using modal.js to pop up dialog box in a page. When the user clicks on a link an iframe will show on a modal dialog box. There is a button inside that iframe. When the button clicks, the modal should be closed and page should redirect to another url. Is it posssible?
You can use jQuery binding to trigger a custom event.
On the click, before you show the iframe, do the following in javascript:
// Bind a trigger
$('body').unbind('myUniqueEventName', SomeJavascriptFunction);
$('body').bind('myUniqueEventName', SomeJavascriptFunction);
Elsewhere in javascript define the function SomeJavascriptFunction:
function SomeJavascriptFunction(event, extraData) {
// This is run when the button on the popup is clicked
// You can pass along data using the extraData parameter
// You can also redirect to another page
var someData = extraData.someData; // Will contain 'someValue'
}
Now all we have to do is trigger the custom event from the iframe. We do this by adding the following code in the iframe when the button is clicked.
parent.$('body').trigger(
'myUniqueEventName', {
someData: 'someValue'
});
});
I have one asp.net page , it consists of some controls along with a close button. If the user clicks on the close button, it will open ModaldialogBox with one text box for entering closing reason. Once the user enters the reason and clicking on the save button, the modal popup shows the alert message and close the modal popup. The existing code for this is shown below.
this.Page.ClientScript.RegisterStartupScript(GetType(), "close", "alert('" + Message + "');var xWin=window.dialogArguments;xWin.location.replace(xWin.location);window.close();", true);
My requirement is that, once the user click on the submit button, I have to navigate to the dashboard page after closing the modal popup window.
I had tried window.location.href after the window.close(), It will open another window and displyed the page. But it should navigate from the existing asp parent page. Please help me for resolving this issue.
Thanks in advance
redirect the parent window with following code
window.opener.parent.location.href = 'dashboardurl';