c# - ASP.NET page not going to server after button click -
i have asp.net page use in popup. pop contains 2 image controls , markup contains jcrop plugin. page, popup opens , hence page loads. reading image in bytes, converting base64 , setting src attribute of both image controls(both have runat='server'). there 2 buttons in page. click on these buttons not hitting event handler page_load, button_clicked etc.
<img id="target" runat="server" alt="main image" /> <img id="imgcropped" runat="server" alt="preview image" class="jcrop-preview" style="border-color:gray" /> protected void page_load(object sender, eventargs e) { strmimetype = session["mimetype"].tostring(); strimagedata = session["imagedata"].tostring(); strimagename = session["imagename"].tostring(); if (!ispostback) { string stemp = "data:" + strmimetype + ";base64," + strimagedata; target.src = stemp; imgcropped.src = stemp; } }
below code when user selects image file , hit uploadclick button.
protected void btnuploadclick(object sender, eventargs e) { httppostedfile objfile = asyncupload.postedfile; if (asyncupload.hasfile) { if (!isimagevalid(objfile)) clientscript.registerclientscriptblock(this.gettype(), "imagenotvalid", "alert('image format wrong. please upload jpeg, png or gif images.')"); else { session["imagedata"] = convert.tobase64string(system.io.file.readallbytes(objfile.filename), 0, system.io.file.readallbytes(objfile.filename).length); session["mimetype"] = objfile.contenttype; session["imagename"] = asyncupload.filename; scriptmanager.registerclientscriptblock(this, this.gettype(), "openpopup", "window.open('imagecroppopup.aspx', 'cropimage', 'height=450,width=700,left=350,top=170,resizable=no,scrollbars=no,toolbar=no,status=no');", true); } } else clientscript.registerclientscriptblock(this.gettype(), "imagenotuploaded", "alert('please select image.')"); }
it not hit page_load @ when click of button. please help.
once place asp.net server control button in jquery popup lose click event in main page. have removed button dom @ point. can try hiding server button jquery on main page, replacing server button standard html button click server button .trigger
event jquery.
like this:
$("#yourhtmlbuttonid").click(function(){ $("#yourserverbuttonid").trigger("click"); });
just remember hide server button jquery , not asp.net's property of visible = false
because won't rendered page if do.
Comments
Post a Comment