Results 1 to 2 of 2

Thread: How do you acheive this in ASP.NET?

  1. #1

    Thread Starter
    Hyperactive Member jeba's Avatar
    Join Date
    Feb 2000
    Posts
    265

    How do you acheive this in ASP.NET?

    Hi there!

    What is the equivlent of the following ASP code in ASP.NET?
    please help.

    Code:
    Sub ValidateValue()
          if Condition=False then
         %> 
             <SCRIPT LANGUAGE=javascript> 
            <!-- 
                  alert("I want to display a msg here & then redirect!"); 
                 //otherwise I would have used Response.Redirect("mainpage.aspx")
                document.location.href="mainpage.asp"; 
            //--> 
           </SCRIPT> 
         <% 
              Response.End 
         end if
    End sub
    Last edited by jeba; Oct 28th, 2002 at 04:15 AM.
    J£ßä

  2. #2
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    Here's one way, kind of a "hacky" way of doin it but it works.
    Code Behind Code:
    VB Code:
    1. Protected MyConditional As Literal
    2. Private Sub Page_Load(ByVal sender As System.Object, _
    3.                       ByVal e As System.EventArgs) Handles MyBase.Load
    4.     'Put user code to initialize the page here
    5.     Dim condition As Boolean = False
    6.     If Not condition Then
    7.         MyConditional.Visible = True
    8.     End If
    9. End Sub

    Webform code(just the Literal control part):
    Code:
    <asp:Literal 
    	Runat="server"
    	ID="MyConditional" 
    	Visible="False"
    	Text="<script language='javascript'>alert('some message');location.href='http://www.microsoft.com/';</script>" />
    Last edited by pvb; Oct 29th, 2002 at 08:02 PM.

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