I have a webform with a button:
<asp:Button ID="btn1" runat="server" text="Click me"
OnClientClick="printVideos(new Object(),new EventArgs(),url,linkName)"/>
and the OnClientClick
event is
<script language= "c#" type="text/C#" runat= "server">
private void printVideos(Object sender, EventArgs e, string url, string linkName) {
for (int i = 0; i < 4; i++) {
Response.Write("<a href='"+url+"'target_blank>'"+linkName+"</a>");
}
}
</script>
Where url
and linkName
are defined in the C# code-behind as private string
s within the class.
The button does not work, and there are warnings showing that url
and linkName
are not used. What should I do to let the markup access to the code-behind variables?