0

Can I somehow evaluate a binding expression like this in codebehind?

" Click('<%#SaveButton.ClientID%>'); DoSomethingElse('<%#CancelButton.ClientID%>')"
3
  • what is the exact use case? of course you can call SaveButton.ClientID in code behind Commented Mar 18, 2011 at 10:02
  • I was hoping that you could use eval to evaluate a string with binding expressions like above for some dynamic stuff. Commented Mar 18, 2011 at 15:43
  • as @Fernando is suggesting, = should do the trick Commented Mar 18, 2011 at 15:45

3 Answers 3

1

You should replace '#' by '='.

Sign up to request clarification or add additional context in comments.

Comments

0

Supposed you used button, you can do sth like that in codebehind:

Button1.Attributes.Add("onclick", "functionName();");

^^

Comments

0

If it's necessary to bind the script on the page. There is some not very elegant way:

<%# String.Format("Click(\"{0}\";DoSomethingElse(\"{1}\")",SaveButton.ClientID,CancelButton.ClientID) %>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.