Thursday 16 August 2012

"Retrieve a Code behind file method in aspx form Page"

default.aspx


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

<!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">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <U>Showtimes for <%WriteDate();%></U>

    </div>
    </form>
</body>
</html>



default.aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class SimpleWebForms : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void WriteDate()
    {
        Response.Write(DateTime.Now.ToString());
    } 
}

No comments:

Post a Comment