Results 1 to 36 of 36

Thread: Popping up a messagebox using ASP.Net???

Threaded View

  1. #31
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Popping up a messagebox using ASP.Net???

    Quote Originally Posted by blakemckenna View Post
    mendhak,

    Then how would I could the statement in post #26? Basically, when the user clicks on a button (if he is not logged in), a message needs to popup letting them know they are not allowed to access that link.

    The way I've thought it out is to set a boolean variable to true if a member of the site has logged in. When a menu button is clicked, a check needs to be made against the boolean variable. How would I do this using that statement in post #26?

    Thanks,
    There are many other ways to do this like using the ClientScript.RegisterStartupScript etc. to insert the javascript code, but this is just the basic way to do this (in continuation of post #26):

    Just give your form body element an ID and add the runat="server" tag to it, so that we can refer to it in code-behind.
    Code:
    <html xmlns="http://www.w3.org/1999/xhtml">
    	<head>
    	    ...
    	</head>
    	<body runat="server" ID="PageBody">
    	    ...
    	</body>
    </html>
    Then the rest of it is similar to what I posted in post #26
    vb.net Code:
    1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.     If Not IsLoggedIn Then     '' replace with whatever way you use to authenticate the user.
    3.         PageBody.Attributes("onload") = "javascript:alert('User is not logged in!');return false;"
    4.     End If
    5. End Sub
    Last edited by Pradeep1210; Nov 23rd, 2009 at 03:42 AM.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width