Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add attributes with hyphen and colon to Html Helper methods in razor? (vuejs syntax)

I want to add v-on:click or @click in like following html helper method:

@Html.TextBoxFor(x => x.ItnScanCaseCode, new { @id="txtid",@click = "onchangeevent();" })

How to do that?

like image 201
Anik Saha Avatar asked Feb 13 '19 13:02

Anik Saha


1 Answers

You could use a Dictionary for htmlAttributes like this:

@Html.TextBoxFor(x => x.ItnScanCaseCode, htmlAttributes: new Dictionary<string, object> {
    { "v-on:click", "onchangeevent()" },
    { "id", "txtid" }
})
like image 51
adiga Avatar answered Nov 14 '22 03:11

adiga