Click here to Skip to main content
15,905,616 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: changing color of edit row in gridview Pin
dilipv21-Feb-08 0:16
dilipv21-Feb-08 0:16 
Questionwhy this error(Server Error in '/' Application) is distrubing the deployed application???? Pin
pashitech20-Feb-08 18:32
pashitech20-Feb-08 18:32 
AnswerRe: why this error(Server Error in '/' Application) is distrubing the deployed application???? Pin
N a v a n e e t h20-Feb-08 20:11
N a v a n e e t h20-Feb-08 20:11 
QuestionHow to use AnimationExtender of Ajax Control Toolkit [modified] Pin
ThienK2720-Feb-08 17:24
ThienK2720-Feb-08 17:24 
QuestionURGENT! - Passing value from one page to another? Pin
John Sundar20-Feb-08 17:12
John Sundar20-Feb-08 17:12 
GeneralRe: URGENT! - Passing value from one page to another? Pin
Abhijit Jana20-Feb-08 19:00
professionalAbhijit Jana20-Feb-08 19:00 
GeneralRe: URGENT! - Passing value from one page to another? Pin
John Sundar20-Feb-08 19:35
John Sundar20-Feb-08 19:35 
GeneralRe: URGENT! - Passing value from one page to another? Pin
Abhijit Jana20-Feb-08 20:35
professionalAbhijit Jana20-Feb-08 20:35 
GeneralRe: URGENT! - Passing value from one page to another? Pin
John Sundar20-Feb-08 20:50
John Sundar20-Feb-08 20:50 
GeneralRe: URGENT! - Passing value from one page to another? Pin
John Sundar20-Feb-08 21:04
John Sundar20-Feb-08 21:04 
GeneralRe: URGENT! - Passing value from one page to another? Pin
N a v a n e e t h20-Feb-08 19:36
N a v a n e e t h20-Feb-08 19:36 
GeneralRe: URGENT! - Passing value from one page to another? Pin
Christian Graus20-Feb-08 21:01
protectorChristian Graus20-Feb-08 21:01 
GeneralRe: URGENT! - Passing value from one page to another? Pin
J4amieC20-Feb-08 23:04
J4amieC20-Feb-08 23:04 
QuestionWhich control can I use? Pin
ss.mmm20-Feb-08 11:28
ss.mmm20-Feb-08 11:28 
AnswerRe: Which control can I use? Pin
Christian Graus20-Feb-08 11:51
protectorChristian Graus20-Feb-08 11:51 
General(performacne) difference between Session and static class Pin
Seishin#20-Feb-08 11:03
Seishin#20-Feb-08 11:03 
GeneralRe: (performacne) difference between Session and static class Pin
Guffa20-Feb-08 11:33
Guffa20-Feb-08 11:33 
Questionconfusion over asynchronous methods inside web service Pin
ekynox20-Feb-08 10:31
ekynox20-Feb-08 10:31 
GeneralRe: confusion over asynchronous methods inside web service Pin
Venkatesh Mookkan20-Feb-08 15:49
Venkatesh Mookkan20-Feb-08 15:49 
GeneralRe: confusion over asynchronous methods inside web service Pin
ekynox21-Feb-08 9:53
ekynox21-Feb-08 9:53 
GeneralDynamic linkbuttons and event wiring Pin
Glenn E. Lanier II20-Feb-08 9:17
Glenn E. Lanier II20-Feb-08 9:17 
I have searched, with no success, for the answer to my problem. I want to dynamically create a linkbutton and programatically set the command to fire when the button is clicked. I can create the button, but the only event that seems to fire is the Page_Load. A simple example is below:

---- File: Test1.aspx ----
<code>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test1.aspx.cs" Inherits="ReportCard.Test1" %>

<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>

</div>
</form>
</body>
</html>
</code>
---- File: Test1.aspx.cs ----
<code>
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 NLog;
using System.Text;

namespace ReportCard
{
public partial class Test1 : System.Web.UI.Page
{
public static Logger logger = LogManager.GetCurrentClassLogger();
protected void Page_Load(object sender, EventArgs e)
{
logger.Info("Page_Load: Postback: {0}", Page.IsPostBack.ToString());
}

protected void Button1_Click(object sender, EventArgs e)
{
logger.Info("Button1_Click");
Table table = new Table();

int i = 1;
TableRow tr = new TableRow();

TableCell tdSysCode = new TableCell();
tdSysCode.CssClass = "tdSysCode";
tdSysCode.Text = string.Format("{0:000}", i);

TableCell tdSysname = new TableCell();
tdSysname.CssClass = "tdSysname";

LinkButton lb = new LinkButton();
lb.CommandName = "lbViewSystem_Click";
lb.CommandArgument = i.ToString();
lb.Command += new CommandEventHandler(lbViewSystem_Click);
lb.Text = string.Format("System {0:000}", i);

tdSysname.Controls.Add(lb);

tr.Cells.Add(tdSysCode);
tr.Cells.Add(tdSysname);

table.Rows.Add(tr);

table.ID = "tblSystemResults";
table.CellPadding = 0;
table.CellSpacing = 0;

TableHeaderRow thrHeader = new TableHeaderRow();
TableHeaderCell thSystemCode = new TableHeaderCell();
thSystemCode.Text = "System Code";

TableHeaderCell thSystemName = new TableHeaderCell();
thSystemName.Text = "SystemName";

thrHeader.Cells.Add(thSystemCode);
thrHeader.Cells.Add(thSystemName);

table.Rows.AddAt(0, thrHeader);
PlaceHolder1.Controls.Add(table);
}

protected void lbViewSystem_Click(object sender, CommandEventArgs e)
{
logger.Info("lbViewSystem_Click");
Literal1.Text = string.Format("Argument = {0} at {1}", e.CommandArgument, DateTime.Now.ToString("MM.dd.yyyy HHmmss"));
}
}
}
</code>

On initial load, click the button, display the link button, then click the link button. You should see a message, but nothing happens.

I've read about creating the link button in the page_load (or on_init) method, but haven't had any success with that either.

Any tips are appreciated.

--G
GeneralRe: Dynamic linkbuttons and event wiring Pin
Christian Graus20-Feb-08 11:50
protectorChristian Graus20-Feb-08 11:50 
QuestionRe: Dynamic linkbuttons and event wiring Pin
Glenn E. Lanier II21-Feb-08 3:07
Glenn E. Lanier II21-Feb-08 3:07 
AnswerRe: Dynamic linkbuttons and event wiring Pin
Glenn E. Lanier II21-Feb-08 4:10
Glenn E. Lanier II21-Feb-08 4:10 
GeneralProgrammatically Setting Virtual Direction Expiration Pin
crystal915420-Feb-08 8:17
crystal915420-Feb-08 8:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.