using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Configuration; using System.Windows.Forms; using System.Net; using System.IO; using System.Collections; public partial class test : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //get the parameters posted from the test if (Page.IsPostBack) { } else { string testname = Request.Form["TestName"]; Label1.Text = testname; } } }
<%@ Page Language="C#" debug="true" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %> <!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> <%--<script type="text/javascript" language="Javascript"> function setValues() { //first check if you get TestName value byusing alert alert(document.getElementById("TestName").value); document.getElementById("Label1").innerHTML = document.getElementById("TestName").value; //give return false to avoid postback return false; } </script>--%> <form id="form1" runat="server"> <div> </div> <p> <asp:Label ID="Label1" runat="server" Text="Label" Font-Size="Larger"></asp:Label> </p> </form> </body> </html>
You must be setting that label some where else false
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { }
protected void Page_Load(object sender, EventArgs e) { if(!Ispostback) { //your code; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)