Non-code behind to code behind

Discussion in 'ASP .Net' started by John, Feb 19, 2007.

  1. John

    John Guest

    Hi

    I have a non code behind web form done previously. How can I turn it into a
    web form with an associated code behind file?

    Thanks

    Regards
     
    John, Feb 19, 2007
    #1
    1. Advertising

  2. John

    Masudur Guest

    On Feb 19, 11:44 pm, "John" <> wrote:
    > Hi
    >
    > I have a non code behind web form done previously. How can I turn it into a
    > web form with an associated code behind file?
    >
    > Thanks
    >
    > Regards


    Hi...
    Lets say you have a page... name Test.aspx
    .... add a class
    Test.aspx.cs
    by default the class is

    public class Test
    {
    public Test()
    {
    //
    // TODO: Add constructor logic here
    //
    }
    }

    modify the class
    public partial class Test:page
    {
    public Test()
    {
    //
    // TODO: Add constructor logic here
    //
    }
    }

    making it partial and inherit from "page"

    now make change the aspx file...

    it should be like this
    <%@ Page Language="C#" %>

    modify it to

    <%@ Page Language="C#" Inherits="Test" CodeFile="~/Test.aspx.cs"
    AutoEventWireup="true" %>

    thats it... you are good to go

    Thanks

    Masudur
    www.kaz.com.bd
     
    Masudur, Feb 19, 2007
    #2
    1. Advertising

  3. Simple way:
    1) add a brand new WebForm.aspx page to your solution.
    2) Copy all your markup from the original to the new
    3) copy all the code between the <script runat=server>... tags into the
    codebehind.
    4) try it and fix any errors.
    --
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short urls & more: http://ittyurl.net




    "John" wrote:

    > Hi
    >
    > I have a non code behind web form done previously. How can I turn it into a
    > web form with an associated code behind file?
    >
    > Thanks
    >
    > Regards
    >
    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Feb 19, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Miller [msft]

    Re: Code Behind vs. no code behind: error

    Ben Miller [msft], Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    654
    Alphonse Giambrone
    Jun 28, 2003
  2. =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=

    Fire Code behind code AND Javascript code associated to a Button Click Event

    =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=, Feb 10, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    21,379
    =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=
    Feb 11, 2004
  3. Daniel Manes

    Code-Behind Pain in the Behind!

    Daniel Manes, Jun 10, 2005, in forum: ASP .Net
    Replies:
    11
    Views:
    714
  4. Robert Dodier
    Replies:
    6
    Views:
    2,418
    Matthias Kraft
    Sep 14, 2004
  5. Kumarforg

    Web Service invocation from behind proxy behind firewall

    Kumarforg, Aug 3, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    217
    Kumarforg
    Aug 3, 2004
Loading...

Share This Page