Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. display alert from code behind

display alert from code behind

Scheduled Pinned Locked Moved ASP.NET
toolshelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    uglyeyes
    wrote on last edited by
    #1

    Hi! I am trying to display alert from code behind. below are my code description. Dim strScript As String strScript = "<script>" strScript = strScript & "alert('please select a value');" strScript = strScript & "</script>" Page.ClientScript.RegisterStartupScript(Me.GetType, "ClientScript", strScript.ToString()) the alert gets displayed fine but everything in the main page disappears. could someone please help me . thanks

    B 1 Reply Last reply
    0
    • U uglyeyes

      Hi! I am trying to display alert from code behind. below are my code description. Dim strScript As String strScript = "<script>" strScript = strScript & "alert('please select a value');" strScript = strScript & "</script>" Page.ClientScript.RegisterStartupScript(Me.GetType, "ClientScript", strScript.ToString()) the alert gets displayed fine but everything in the main page disappears. could someone please help me . thanks

      B Offline
      B Offline
      bhanu12345
      wrote on last edited by
      #2

      Hi, If you want to show alert messages on button click then in pageload event write button1.attributes.add("onclick","return showalert()"); and in the aspx page write a javascript function to get the alert messages. Reply me if it doesn't work for you. Bhanu

      U 1 Reply Last reply
      0
      • B bhanu12345

        Hi, If you want to show alert messages on button click then in pageload event write button1.attributes.add("onclick","return showalert()"); and in the aspx page write a javascript function to get the alert messages. Reply me if it doesn't work for you. Bhanu

        U Offline
        U Offline
        uglyeyes
        wrote on last edited by
        #3

        the link button i have is in the datalist. so when i write above it doesn't fires in first click but it does fires if i click second time. below are my codes. Private Sub dlParent_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlParent.ItemCommand If e.CommandName = "select" Then Session("MenuId") = e.CommandArgument.ToString End If Dim menuHead As LinkButton = CType(e.Item.FindControl("lnkParent"), LinkButton) If menuHead.Text = "Property View" Then If Session("locationid") <> Nothing Then Response.Redirect("PropertyDetail.aspx") Else menuHead.attributes.add("onclick","return displayalert()");---this doesnt work in first click End If ElseIf menuHead.Text = "Portfolio View" Then Response.Redirect("PortfolioCapex.aspx") End If End Sub

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups