inline code not executing?

Discussion in 'ASP .Net' started by jason, Sep 7, 2005.

  1. jason

    jason Guest

    Hello everyone,

    Just curious what would cause an .aspx page to not execute its inline
    code. <%# DataBinder.Eval... %> stuff is working just fine, but
    anything else contained by the <% %> tags in the .aspx page just gets
    sent literally to the client, including the <% %> tags themselves.

    I read something about this being related to AutoEventWireup in the
    page directive, but it occurs whether that value is true, false, or not
    even present in the page directive.

    Any ideas?

    Thanks,

    Jason
     
    jason, Sep 7, 2005
    #1
    1. Advertising

  2. jason

    Nick Guest

    Post your code out and let's have look. The problem should be easy.
     
    Nick, Sep 7, 2005
    #2
    1. Advertising

  3. jason

    jason Guest

    hehe, been trying to widdle down a managable version to post, and i
    think i've got one (if anyone is still reading this thread). so here is
    a slightly miniaturized version:

    (ASPX)

    <%@ Page language="c#" Codebehind="Test.aspx.cs"
    AutoEventWireup="False" Inherits="polaris.Test" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD><title>Test</title></HEAD>
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:datagrid id="DataGrid1" runat="server"
    AutoGenerateColumns="False" ShowFooter="True">
    <columns>
    <asp:templatecolumn headertext="Name">
    <itemtemplate>
    <asp:label id="Label1" runat="server" text='<%#
    DataBinder.Eval(Container.DataItem, "Name") %>' />
    </itemtemplate>
    <footertemplate>
    <asp:textbox id="Textbox1" runat="server" text='<%=
    Request["thingy"] %>' />
    </footertemplate>
    </asp:templatecolumn>
    <asp:templatecolumn headertext="Action">
    <itemtemplate />
    <footertemplate>
    <asp:linkbutton commandname="AddSchedule" id="Button2"
    runat="server" text="Add" />
    </footertemplate>
    </asp:templatecolumn>
    </columns>
    </asp:datagrid>
    <asp:Label id="Label2" runat="server" /><br />
    <asp:Label id="Label3" runat="server" />
    </form>
    </body>
    </HTML>

    (CODE BEHIND)

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;

    namespace test
    {
    public class Test : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.DataGrid DataGrid1;
    protected System.Web.UI.WebControls.Label Label2;
    protected System.Web.UI.WebControls.Label Label3;

    DataTable oTable;

    private void Page_Load(object sender, System.EventArgs e)
    {
    if (!Page.IsPostBack)
    {
    oTable = new DataTable();
    oTable.Columns.Add("Name");
    object[] R1 = new object[] { "John" };
    object[] R2 = new object[] { "Jane" };
    object[] R3 = new object[] { "Jack" };
    object[] R4 = new object[] { "Jill" };
    oTable.Rows.Add(R1);
    oTable.Rows.Add(R2);
    oTable.Rows.Add(R3);
    oTable.Rows.Add(R4);
    DataGrid1.DataSource = oTable;
    DataGrid1.DataBind();
    }
    }

    #region Web Form Designer generated code
    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 modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.Load += new System.EventHandler(this.Page_Load);
    }
    #endregion
    }
    }


    the question primarily resides in the ASPX file. the DataBinder.Eval
    statements work just fine, but the inline code to, say, pull a request
    querystring variable value, don't work.

    thanks for any advice!

    jason
     
    jason, Sep 8, 2005
    #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. Abhi
    Replies:
    2
    Views:
    751
    E. Robert Tisdale
    Jul 3, 2003
  2. Alvin
    Replies:
    7
    Views:
    489
    E. Robert Tisdale
    May 6, 2005
  3. Replies:
    3
    Views:
    473
  4. Nish
    Replies:
    4
    Views:
    510
    Thomas Stegen
    Oct 8, 2004
  5. Jon Slaughter

    to inline or not to inline

    Jon Slaughter, Apr 20, 2007, in forum: HTML
    Replies:
    9
    Views:
    359
    Andy Dingley
    Apr 20, 2007
Loading...

Share This Page