Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 %>?');" />
like image 725
Dustin Getz Avatar asked Nov 26 '25 00:11

Dustin Getz


2 Answers

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) + "?');"; 
like image 139
RichardOD Avatar answered Nov 27 '25 15:11

RichardOD


You need to set the property so that it is all from a render block or completely with out. Give this a try

<asp:LinkButton ... OnClientClick=
    "<%= "return confirm('Are you sure you want to remove Contract 
        Period " + ContractPeriod_N.Text + "?');" %>" />
like image 44
Bob Avatar answered Nov 27 '25 13:11

Bob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!