onClick Event Not Firing

R

RitaG

Hello.

I posted this question in the C# discussion group but am posting it here
also since ASP is involved.

I'm new to C# and need some help regarding an onClick event not firing.

I have a data grid that I add a cell to programatically. The cell is a
hyperlink and the onClick is set to _doPostBack. In my code I handle the
event but when I click on that added hyperlink nothing happens.

Here's my code (I'll just show the relevant stuff).
The data grid is dgBillSummary.

In MyClass.ascx I have a hidden LinkButton:
<asp:LinkButton id="lnkPostBack" runat="server" Height="1px"
Visible="False">PostBack</asp:LinkButton>

Here's MyClass.ascx.cs
public class MyClass
protected System.Web.UI.WebControls.LinkButton lnkPostBack;
|
private void InitializeComponent()
this.lnkPostBack.Click += new System.EventHandler(this.lnkPostBack_Click);
|
private void dgBillSummary_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
|
Label lblShowAll = new Label();
lblShowAll.Text = "<a name=\"#ShowAll\" class=\"HypLink\"
onContextMenu=\"NoContextmenu();\" href=\"#ShowAll\"
onClick=\"_doPostBack('lnkPostBack','ShowAll');\"> Show All</a>";

e.Item.Cells[0].Controls.Add(lblShowAll); // here I'm adding a cell to the
data grid

|

// Here's the onClick event code that I never get to
private void lnkPostBack_Click(object sender, System.EventArgs e)
{
|
}

Any suggestions will be greatly appreciated!

TIA,
Rita
 
A

Anthony Jones

RitaG said:
Hello.

I posted this question in the C# discussion group but am posting it here
also since ASP is involved.

Actually it's ASP.NET that's involved so you'll need to post it again to:-

microsoft.public.dotnet.framework.aspnet
 

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

Members online

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top