Try our conversational search powered by Generative AI!

if (!IsPostBack) { // } -- always false?

Vote:
 
Hi! I'm trying do to a very simple task for testing purposes, change a label text when a user clicks a button. I create a new template and assign it to my masterpage, create a label and a button. After the successful compilation, I try it in the EPiServer edit mode after adding it as a new page type. This is where strange things start to happen: When I click the button in the edit-mode the label changes, but when I try it outside edit mode, the button_OnClick-event never occurs. Any Ideas? my aspx-template: <%@ page language="C#" masterpagefile="~/templates/MasterPages/MyMaster.Master" autoeventwireup="true" codebehind="formtest.aspx.cs" inherits="EPiServerSample.templates.formtest" title="Untitled Page" %> My CS-file: using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using EPiServer; namespace EPiServerSample.templates { public partial class formtest : TemplatePage { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Button clicked."; } } } /Jonas
#12872
Dec 15, 2006 8:27
Vote:
 
Make sure you have this somewhere inside the head tag: (in the demo site, it is in the /templates/units/header.ascx file) /Steve
#15022
Dec 15, 2006 10:50
Vote:
 
That was it! Thank you very much for your answer. Best regards, /Jonas
#15023
Dec 15, 2006 13:28
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.