Results 1 to 5 of 5

Thread: Easy way to get index page from php to asp

  1. #1
    Join Date
    Apr 2010
    Posts
    30

    Easy way to get index page from php to asp

    I have done it in php and is now trying to do the same in asp.net. In php I've done something like this

    HTML Code:
    <html>
    <body>
    <?php
    if( $_GET['page'] == "index" )
    include('home.php')
    else if( $_GET['page'] == "login" )
    include('login.php');
    Can you try and teach me some asp.net (with c#). Should I add the code in the aspx or aspx.cs for index.aspx page? And what should the code be?

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Easy way to get index page from php to asp

    I have searched for your problem on Google and it gave me the following:

    HTML Code:
    Request.QueryString["page"]
    Request.QueryString["page"] will get the page url parameter. Request.Form["variable"] will give you the POST fields. Includes exist in ASP.NET, but only for compatibility with classic ASP. But I would recommend you to create a User Controls instead. And always remember that it is always good to have a program against controls and then generate HTML.

  3. #3
    Join Date
    Apr 2010
    Posts
    30

    Re: Easy way to get index page from php to asp

    I know all this things. However the url looks something like this: .. /index.aspx?page=login. WHAT and WHERE in the code do I test? I have the following in my index page, in the body:
    Code:
    <%
        if( Request.QueryString["page"] != null )
        {
            if (Request.QueryString["page"].Equals("login"))
                Response.Write("LOGIN PAGE");
        }
        else
            Response.Write("MAIN PAGE");
    %>
    But I'm stuck on what to do to include the correct pages. After some searching, guessing and results I have come up with something. But wonder if this is the best way to do it. I have then in advance about 2 "Web User Controls", login and main. login.ascx. Anybody have any objections? Is this incorrect use of the Web User Controls to what I'm trying to achieve (.. /index.aspx?page=abc).

  4. #4
    Join Date
    Nov 2008
    Posts
    1,192

    Re: Easy way to get index page from php to asp

    No it's certainly not a good way to do it. If you really want to do something similar to this in ASP.NET, you can look at Master Pages. Does not really understand why you want to do it this way other than proper url. But if you absolutely have to, then you can just run something like this...

    Reading QueryString
    Open the file that points to the QS with a normal System.IO function.
    Perform file out again with Response.Write

  5. #5
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Easy way to get index page from php to asp

    Previously I was using VB.NET but when I write ASP.NET pages this is how it is done that does the same operation.

    Code:
    <%@ Page Language="VB" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <script runat="server">
     Sub _onload(sender as Object, e as System.EventArgs) Handles Me.Load
      Dim page As String = Request.QueryString("page")
      Select Case page.ToLower
       Case "login"
            myContent.Controls.Add(LoadControl("./ControlFolder/Login.ascx"))
       Case Else
            myContent.Controls.Add(LoadControl("./ControlFolder/Main.ascx"))
      End Select
     End Sub
    </script>
    <head>
            <title></title>
    </head>
    <body>
     <div id="myContent" runat="server"></div>
    </body>
    
    </html>

Similar Threads

  1. How much time will google take to index my page again
    By Daisuke in forum Technology & Internet
    Replies: 3
    Last Post: 16-01-2011, 01:31 AM
  2. Does Google decides which content to index & what not to index?
    By Uddhav in forum Technology & Internet
    Replies: 5
    Last Post: 04-03-2010, 07:37 PM
  3. How much time does Google takes to index a page
    By KALANI84 in forum Technology & Internet
    Replies: 3
    Last Post: 31-08-2009, 11:12 PM
  4. Inserting an index entry into index 0 of file 25
    By Dharmesh Arora in forum Operating Systems
    Replies: 3
    Last Post: 16-07-2009, 10:10 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,669,891,875.08032 seconds with 17 queries