ASP Beginner

Discussion in 'C#' started by aravindns, May 25, 2009.

  1. #1
    Hi,

    Iam new to ASP programming,

    iam devloping a sample application using Web devloper express 2008,

    In my application ,iam having 2 asp pages(in VB ) default.aspx and page2.aspx

    iam trying to call a function which is in page2.asp from default.asp,how to do this?

    i know that i need to create an instance of class and call the function ,but how to do this in ASP?

    Please help,

    Thanks in advance,
     
    aravindns, May 25, 2009 IP
  2. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    This looks to be using ASP.NET.. do the pages have the code-behind file? e.g default.aspx.vb and page2.aspx.vb
     
    camjohnson95, May 25, 2009 IP
  3. Social.Network

    Social.Network Member

    Messages:
    517
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #3
    Yes, this is ASP.NET. First, why do you want to call a function on another page? I am afraid to ask, but if this is common code it should be in a shared class not embedded in the code-behind of the other page. Also, the code-behind should be limited to event-handlers, validation, and other UI-specific functionality. It should consume business services as needed too. Please revisit your design.
     
    Social.Network, May 25, 2009 IP
  4. rnvr

    rnvr Well-Known Member

    Messages:
    121
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #4
    Kindly make a class, go to App_code folder,right click add items, add a class file, give it some name...

    in the class file , add a namespace

    eg:
    imports system.****
    imports system.****

    namespace myclass
    public class xyz
    public shared function myfunction()
    <-- your code -->
    end function
    end class
    end namespace

    -------------------------------
    now call this class function in your both the code behind files like this

    imports myclass <-your namespace name here
    partial class default
    sub page load
    dim x as new xyz <- your class name in the namespace
    'then
    x.myfunction()
    end sub
    end class

    -------------------

    this is the way how you show do that
    if any problems, mail me at , and i will send you a nice ebook for ASP.NET
    :)
     
    rnvr, May 26, 2009 IP