How to pass int from jquery to c# code block in a view -
i use jquery id of clicked image, , able id. want use id call image again database using c# code block. jquery code:
$(document).on('click', '.thisimage', function () { alert(this.id); });
this code using call again image:
int id = // image of clicked image should passed on int id's value. using (the_factory.models.the_factorydbcontext db = new the_factory.models.the_factorydbcontext()) { if (db.treasures.firstordefault(treasure => treasure.treasureid == id).itemimage != null) { byte[] chosenimage = db.treasures.firstordefault(treasure => treasure.treasureid == id).itemimage; string imagesource = ""; string imagebase = convert.tobase64string(chosenimage); imagesource = string.format("data:image/gif;base64,{0}", imagebase); <img id="thisimage" src="@imagesource" width="100" height="100" /> } }
Comments
Post a Comment