Search code examples
asp.netascxdelimiter

inline dynamic string in ascx


This doesn't execute the delimiter (its displayed verbatim in the confirm dialog). Why not? Also, that variable is set in the codebehind, but is ready by the time PreRender gets called, so I should be OK right?

<asp:LinkButton ... OnClientClick=
    "return confirm('Are you sure you want to remove Contract 
        Period <%= ContractPeriod_N.Text %>?');" />

Solution

  • Try doing it in the code behind:

           theLinkButton.OnClientClick = 
    "return confirm('Are you sure you want to remove Contract Period " +  
        Server.HtmlEncode(ContractPeriod_N.Text) + "?');";