Code behind not running

G

Guest

I have the following web form:
<%@ Page language="c#" Codebehind="ProductsT.aspx.cs" AutoEventWireup="false" Inherits="loyaltynz.ProductsT" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><html><head><title>ProductsT</title><meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"><meta name="CODE_LANGUAGE" Content="C#"><meta name=vs_defaultClientScript content="JavaScript"><meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5"><link rel="stylesheet" href=<%# setStyleSheet () %>></head><body MS_POSITIONING="GridLayout"><form id="Form1" method="post" runat="server"><%# setStyleSheet () %></form></body></html

with the following code behin
using System
using System.Collections
using System.ComponentModel
using System.Data
using System.Drawing
using System.IO
using System.Web
using System.Web.SessionState
using System.Web.UI
using System.Web.UI.WebControls
using System.Web.UI.HtmlControls

namespace loyaltyn

/// <summary
/// Summary description for ProductsT
/// </summary
public class ProductsT : System.Web.UI.Pag

private void Page_Load(object sender, System.EventArgs e

// Put user code to initialize the page her

public string setStyleSheet(

if (File.Exists(Server.MapPath (Session["Campaign"] + ".css")))
return Session["Campaign"] + ".css"
else
return "default.css"


#region Web Form Designer generated cod
override protected void OnInit(EventArgs e

/
// CODEGEN: This call is required by the ASP.NET Web Form Designer
/
InitializeComponent()
base.OnInit(e)


/// <summary
/// Required method for Designer support - do not modif
/// the contents of this method with the code editor
/// </summary
private void InitializeComponent(
{
this.Load += new System.EventHandler(this.Page_Load)

#endregio


can anyone explain what to do when the code doesn't execute this is rather urgent
 
G

Guest

Many Thanks, that worked a treat and solved my OnPageIndexChange event not firing. The controls got confused by me adding a literal at 0 to set the style sheet, this is a much more elegant way of doing things
Could you tell me the significance of the # compared to = after the <% construct and any other switches you can place there.
 
M

Martin Dechev

Hi, Timothy,

<%# is used only when there is some databinding involved. The expression
inside this server tag gets evaluated on calls to DataBind() on different
binding controls. See:

http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconDatabindingExpressionSyntax.asp

<%=string%> is equvalent of <%Response.Write(string)%>. See:

http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconCodeRenderBlocks.asp

Hope this helps
Martin
Timothy Elvidge said:
Many Thanks, that worked a treat and solved my OnPageIndexChange event not
firing. The controls got confused by me adding a literal at 0 to set the
style sheet, this is a much more elegant way of doing things.
Could you tell me the significance of the # compared to = after the <%
construct and any other switches you can place there.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top