开发者

How to display a notification in asp.net

开发者 https://www.devze.com 2023-02-13 01:13 出处:网络
I\'m trying to display a notification using Easy Notification, but I don\'t want it to be displayed every time the page is loaded, but when it only has something to show

I'm trying to display a notification using Easy Notification, but I don't want it to be displayed every time the page is loaded, but when it only has something to show

Try
  mailClient.Send(mail)
  ' ........      
  ' "message" is the hidden field that stores the string message to dis开发者_开发知识库play
  message.Value = "Message sent."

Catch ex As Exception     
  message.Value = ex.Message
End Try

If the value of the hidden field is different from empty string, display the message it has , otherwise display nothing

<script type="text/jscript">  
$(document).ready(function() {
if ($("[id$=_message]").val()!=""){
  $.easyNotification({
        text: $("[id$=_message]").val()
      }
      );    
     //Set hidden field's value to empty string 
     $("[id$=_message]").val()="";
    }
  
});   

As you can see, I'm not clear on how to get/set the value of the hidden field

EDIT-----

I tried using smokesignals.

  1. Added the dll to the bin folder
  2. Put a placeholder control called plhMessages on my page and
  3. called SendMessage from the load event of my page,but nothing happens. :( Am I missing something???

ASP.Net

   <form id="form1" runat="server">
        <asp:Panel ID="Panel1" runat="server">
            <asp:PlaceHolder ID="plhMessages" runat="server">
            </asp:PlaceHolder>                
        </asp:Panel>
</form>

VB

Protected Sub btnSend_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Load
    SendMessage(MessageType.Error, "This is an error message set from the aspx page.", True)
End Sub


If you had in the page a hidden field like:

<input type="hidden" id="_message" value="Some text"/>

Then I assume the following should work:

$(function()
{
   var field = $('#_message');
   if(field.val() !== '')
   {
      $.easyNotification({text: field.val()}); 
   }

});

Probably you want to read:

http://api.jquery.com/category/selectors/


if your using .net I've got a library that I use for displaying messages, smokesignals@github, really simple and straight forward.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号