This is a migrated thread and some comments may be shown as answers.

[Solved] How to write Inline function of Client Event in Razor view

1 Answer 28 Views
Slider
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Keyur
Top achievements
Rank 1
Keyur asked on 12 Jan 2012, 06:33 AM
@{Html.Telerik()
            .RangeSlider<double>()
            .Name("RangeSlider")
            .Min(0)
            .Max(24)
            .Values(2, 5)
            .SmallStep(1)
            .LargeStep(5)
            .Orientation(SliderOrientation.Horizontal)
            .ClientEvents(events =>
                events.OnChange(() => @<text> function(e){ alert("df");} </text>)
                  
            )
            .Render();}

1 Answer, 1 is accepted

Sort by
0
Bruno
Top achievements
Rank 1
answered on 11 Mar 2013, 06:00 PM
Bump!

I do have the exact same question for the same example. I'm trying to build javascript function on the server side based on the model's content. I can't figure out how to do inline JS functions with Razor.


<div class="slider-container">
        @(Html.Telerik().Slider<double>()
              .Name("Slider" + f.fld_id)
              .Min(1)
              .Max(f.MaxNbCPsSrcs)
              .SmallStep(1)
              .LargeStep(5)
              .Orientation(SliderOrientation.Horizontal)
              .ShowButtons(false)
              .HtmlAttributes(new { style = "width:300px;" })
              .Value(f.selected_cp)
              .TickPlacement(SliderTickPlacement.None)
              .ClientEvents(events => events
                    .OnChange((Action)(() =>
                    {                            @<text> function(e) {  } </text>;
                    }))
                 
               )
        )
    </div>

returns: error CS0201: Seuls une assignation, un appel, un incrément, un décrément et des expressions d'objet new peuvent être utilisés comme instruction.

sorry for french error msg.
Tags
Slider
Asked by
Keyur
Top achievements
Rank 1
Answers by
Bruno
Top achievements
Rank 1
Share this question
or