I have a problem that I think should be simple.
In codebehind file in C# I have a loop that gets a string on each pass. I need to display that string on the page. I need it so that when someone clicks the text on the page that it will then call my On_Click method in the C# codebehind file. I will also need a way to determine the text that was clicked.
I have something like:
It gives me an error on page when text is clicked.
I can't use javascript. It has to be codebehind.
Thank You for any help that you can give me.
Denny
In codebehind file in C# I have a loop that gets a string on each pass. I need to display that string on the page. I need it so that when someone clicks the text on the page that it will then call my On_Click method in the C# codebehind file. I will also need a way to determine the text that was clicked.
I have something like:
Code:
protected void Page_Load(object sender, EventArgs e)
{
foreach (string s in stringArray)
{
HtmlAnchor a = new HtmlAnchor();
a.Attributes.Add("onclick", "On_Click()");
a.Attributes.Add("runat", "server");
a.InnerText = s;
ExistingTag.Controls.Add(a);
}
}
I can't use javascript. It has to be codebehind.
Thank You for any help that you can give me.
Denny
Comment