1

その場でアンカータグを作成しています。作成されますが、何らかの理由で機能しonClickていません。

ここに私の生成コードがあります:

HtmlGenericControl emailsubject = new HtmlGenericControl("div");
emailsubject.ID = count++ + "emailSubject";
emailsubject.InnerHtml = "Subject: " 
    + "<a id=\"summa\" href=\"#\" onClick=\"subject_Click();\">" 
    + results2["EmailSubject"].ToString() 
    + "</a>";

これが私のonClick機能です:

public void subject_Click()
{
    Response.Write("Clicked");
}
4

1 に答える 1

2

The way you have it set up right now, you're trying to call a javascript function from an html element. Try either initializing the onclick function of the control you are creating or make use of another asp.net control (ASP:Hyperlink) in order to call functions in code behind.

于 2013-04-17T16:00:20.663 に答える