In .aspx how to pass value from asp: Repeater to code behind function

So I want to use jquery to set the text of a button based on the value of a property on the current line of the relay.

I need to call a function in code to map the value to the text that the button should have. So, I need to go to my foo function, the string value of the UserStatus property for the current element in the relay.

I want to do the following, although this syntax is obviously not correct:

<asp:Repeater ID="dgCustomer" runat="server">
  <ItemTemplate> 
    <input id="rb" name="rb" type="radio" onclick='javascript:$("input.magicbutton").val("<%= foo(DataBinder.Eval(Container.DataItem, "UserStatus")) %>");' 

      

If the codebehind contains the following method definition:

protected string foo(string status)

      

What is the correct syntax to call foo using the Item value from the relay?

0


source to share


2 answers


Switch <% = with <% # and it looks like you should be good to go.



+2


source


The only problem I see with this code snippet is that instead of the expression nugget ( <%= ... %>

), you need to use the bootstrapped databinding ( <%# ... %>

).



You may have problems with the double quoted zamoros surrounding your, as it contains double quotes. Maybe you need to return the foo

quoted value, or even have to foo

just return the whole event onclick

...

+1


source







All Articles