Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a web application in which i have different form to get input from user,when user press save button a massage is displayed using this code in the site.master
<asp:UpdatePanel runat="server">
    <contenttemplate>                                                
      <asp:Literal runat="server"  ID="_alert">
      <asp:ContentPlaceHolder runat="server" ID="MainContent">
    </contenttemplate>


and using script code as follow:
$(".alert").alert('close');


if i use this code then there is no error or successful message is displayed ,just all fields clear and ready for next entry.
and if i use (_alert) instead then message is displayed but it does not hide. i want that on each entry message is displayed and vanished after few second and form is ready for next entry.plz help me out
Posted
Updated 29-Sep-14 19:58pm
v2
Comments
[no name] 30-Sep-14 0:16am    
Since you are using the Master page , you must get the clientID first.Then try the same with clientID.
Sajid227 30-Sep-14 13:22pm    
how to get client id in this situation
Sinisa Hajnal 1-Oct-14 2:16am    
You have that part in my solution: use <% %> "tags" for server side writing into the document

You can take the advantage of "data-dismiss" attribute.
like as below
<div id="ANY" style="display: none; width: 700px;" class="modal hide fade in">
    <div class="modal-header modal_header_back">
        <a class="close" id="aClose" data-dismiss="modal"</a>
        <h4>Any</h4>
    </div><br />
    <div id="ANY" class="modal-container-padding issueDetailsContainer">
       //content here..
    </div>
</div>


You can trigger the close by:
//add delay if required..
$("#aClose").trigger('click');

Hope this helps
Thanks
:)
 
Share this answer
 
Use jQuery.fadeOut[^] calling
JavaScript
$('<%=_alert.ClientID%>').alert().fadeOut(1000); 

or some variation thereof to hide the message in 1 second.

_alert.ClientID is needed because server-side controls get their IDs mangled by the server...if you use class-name then you can use
JavaScript
$(".alert").alert().fadeOut(1000); 

but you need the class on the literal then.
 
Share this answer
 
v2
Comments
Sajid227 30-Sep-14 13:54pm    
i have tried Your code but when i try to close alert message by clicking on cross button then different fields where required is used popup.
Sajid227 30-Sep-14 13:56pm    
<ajaxToolkit:ToolkitScriptManager runat="server">


<script>
{
$('.date-picker').datepicker({ dateFormat: 'dd/mm/yyyy' });
$('.search-select').select2();
$('.time-picker').timepicker();
$(".alert").alert().fadeOut(10000);


}
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
</script>

and here in updatepanel
<asp:UpdatePanel runat="server">
<contenttemplate>
<asp:Literal runat="server" ID="_alert">
<asp:ContentPlaceHolder runat="server" ID="MainContent">


Sinisa Hajnal 1-Oct-14 2:15am    
You need class="alert" on _alert literal or your fadeOUt will never be called.
Sajid227 1-Oct-14 14:19pm    
i tried it by taking class in updatepanel but no effect. as i used _alert then message is displayed but it does not fade away instead required field message is displayed when i fill up form again then alert message is disappeared
Sinisa Hajnal 2-Oct-14 2:34am    
That means it doesn't get called. Check your console.log in developer tools of the browser to see if there is javascript errors.

I think you misunderstood something. I thought you're calling alert on div change...but you're initializing alert() and immediately calling fadeOut()...you should call fadeOut when you SHOW the alert not upon page load. - maybe I'm misreading something from partial code...please check your browser console and see if there are errors in javascript.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900