i am trying to show a hidden div after a login button click event..but the div is not staying..it is vanishing after the login click..but i want to stay the div after login button click and it will stay in the page untill i click anything in the page..
my button
<asp:Button ID="loginbutton" runat="server" Text="Login" OnClientClick=" return someFunction();"/>
my javascript function
<script type="text/javascript">
function someFunction() {
$("#logdiv").show();
}
</script>
Here the div is not stay visible after the click of your button because you make at the same time post back, after the reload of the page the div is hidden again.
I am not suggest you to hold the post back because probably is not what you want. You can try either render the div again with visible on, either register some other script after the post back to make it visible.
Related
I need a solution which makes element visible after history.back triggered.
Initially, the div is hidden on a page. After a user clicks the button, the div becomes visible. Then then user visits another link and load page2. When user clicks Back button on browser from page2, I want to make the div is still visible on page1.
Page1 - HTML:
<html>
...
<body>
<div class="the-div hidden">
<h4>You see me now!</h4>
</div>
<button onclick="foo()">Click me!<button>
</body>
</html>
Page1 - JS:
foo = function(){
$(".the-div").removeClass("hidden");
// Expects the code here with history.pushState or something ..
}
Try to explore localStorage.
localStorage.setItem('buttonClicked', false);
on click of button, change the value of localStorage
I follow How to clear a textbox using javascript but my scenario is little change. I have a login button and when user click on login a pop-up window is open. He fill the textbox and for some reason he go back to main page. When he again come to login popup window he previous value is not cleared. May be this is because the page is not loaded. And I do not want to load page again. I want to use JQuery/JavaScript to remove the entered text. I has idea that I write code inside Close button but I don't know how to clear the textboxes. Please help.
Here is the code, scenario is that I used popup for login and sign up. In login popup there is link "Don't have login Id" when user click on it the sign up pop up with form is open.
Don't have Login Id
And the JavaScript method is
<script type="text/javascript">
function function_deletePreviousData(){
document.getElementById("signUp").value = "";
}
</script>
But nothing happened. I think this is because I don't give element id, I just give id of element which I used to land on sign up pop up form. Any idea for clear all form without accessing all elements and give it null value.
Instead of including code in close button click event, we should write code in login button click.This is one of my suggestion.
Try this once:
Javascript:
<script type="text/javascript">
function LoginButtonClick() {
document.getElementById`("TextBox_Id").value = "";
}
</script>
JQuery:
jQuery("#LoginButton_Id").Click( function()
{
$('#TextBox_Id').val("");
} );
Finally I find the method in JQuery to reset all fields. Just Trigger reset.
$('#form').trigger("reset");
Thanks all for help.
I am trying to click a button in parent page from pop-up child window. The parent page uses a master page while the child window doesn't. My code works whenever the parent page has no master page but when there is it didn't.
Below is my code.
function clickParent()
{
document.getElementById('<%=btnclick.ClientID %>').click();
}
function callClick()
{
window.opener.clickParent();
}
I call the callClick() function in child page button like this..
ScriptManager.RegisterClientScriptBlock(Me.Page, Me.[GetType](), "parentRel", "clickParent();", True)
Thanks in advance.
This is because, when we add master page all the id will be contactinated with some additional string .
To avoid this add attribute ClientIdMode="Static" to all the asp controls.
Eg:
<asp:TextBox ID="TextBox1" ClientIDMode="Static" runat="server"></asp:TextBox>
I've got an old application in ASP.NET. In a form with a Submit button, I put this div at the top of the page:
<div id="submitIndication" class="saveIndication" runat="server" visible="false">
Your request has been submitted.
</div>
On btnSubmit_Click in the code-behind, I put this line:
submitIndication.visible = true
This code then handles a fading out of the div:
jQuery(document).ready(function () {
setTimeout(fadeOut, 4000);
});
function fadeOut() {
jQuery("#submitIndication").slideUp(400);
};
That all works fine. However, there are two other buttons on the page, "Prefill Form" and "Opt Out". These call their own methods (btnOptOut_Click and btnPrefillFormInfo_Click), neither of which touches the submitIndication div in any way.
But, after I submit the form the first time, when I click Prefill Form or Opt Out, the page refreshes, and the submit div appears at the top again. If I click them before submitting, this doesn't happen.
It seems the div is still on the page at this point, and just displaying until the JavaScript fades it out. I've tried all manner of things (setting CSS visible to false and display to none, remove(), hide(), attr(), etc.), and nothing seems to get rid of this div.
This feels like it should be so simple. How can I get this div to not show up after a submit and clicking other buttons?
Try this:
Declare DIV as:
<div id="submitIndication" class="saveIndication" runat="server" style="display:none">
Your request has been submitted.
</div>
And on btnSubmit_Click in the code-behind put this line (assuming u're using C#):
submitIndication.Style["display"] = "block";
And use your current fadeout code.
Update Come to think of it even simpler approach should work. Keep everything as it is in your setup, just add EnableViewState = "false" to your DIV's HTML definition.
In my application when i click form submit, service call happens. When the service call happens I need to I need to disable the page conetent til the next page loads.
As i have given cursor:wait the mouse pointer changes to loading symbol and does not allow to click on the page. But still i could use tab and enter or change the values in the page.
Can anyone tell the code to disable page content using transparent image?
You could do that easier than with a transparent image :
$('body.waiting > *').on('click', function(e) {
e.preventDefault();
});
I think that you should only disable the submit input for example :
$('input').attr('disabled', 'disabled');
With a "overlay", add an absolute div at the top of your page :
<div id="overlay" style="position:absolute;background:url('trans.png');left:0;top:0;width:100%;height:100%;display:none;"></div>
And than simply show it when your form is submitted :
$('#overlay').show();