Adding toastr javascript asp.net webform

前端 未结 2 795
甜味超标
甜味超标 2021-02-13 18:06

I am trying to display a toastr message (info,error etc) after submitting a form using a button and update a gridview control (which is in a update panel\" in asp.net webform. T

2条回答
  •  感情败类
    2021-02-13 18:31

    Calling from web form, (note this is a MasterDetail form so has a MasterPage.

    MasterPage.ShowToastr(Page, "Message Here", "Title Here", "Info", False, "toast-bottom-full-width", False)

    The VB.NET ShowToastr implementation in the Master Page (VB)

    Public Shared Sub ShowToastr(ByVal page As Page, ByVal message As String, ByVal title As String, Optional ByVal type As String = "info", Optional ByVal clearToast As Boolean = False, Optional ByVal pos As String = "toast-top-left", Optional ByVal Sticky As Boolean = False)
        Dim toastrScript As String = [String].Format("Notify('{0}','{1}','{2}', '{3}', '{4}', '{5}');", message, title, type, clearToast, pos, Sticky)
        page.ClientScript.RegisterStartupScript(page.[GetType](), "toastr_message", toastrScript, addScriptTags:=True)
    End Sub
    

    The Javascript function ShowToastr resides in the master page as a shared function.

      
    
    
    
    
    
    
    
    
    
    

    I hope this helps someone, as I tried for ages to get the toastr options integrated in one call. If you want to have more options available on the call to toastr, then add more parameters to the functions. All of the options that can be set are in the commented code (javascript).

提交回复
热议问题