Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi ,
I am using Image control to upload persons image to system.Using upload control i am setting image source for image control and it shows correctly.But on a dropdown value change(postback) the image does not showing on the control but even if i save the data it will go to database and on recall it comes correctly.During postback the image control does not display the source image .
Please help me to clear the issue.

Thanks
Regards
Nidhin

[edit]SHOUTING removed - OriginalGriff[/edit]
Posted
Updated 2-Oct-15 23:00pm
v2
Comments
Krunal Rohit 3-Oct-15 4:54am    
Can you please share your code ?

-KR
NIDHIN.C 3-Oct-15 5:09am    
<div style="float: left; width: 122px; vertical-align: baseline;">
<dx:ASPxUploadControl ID="uplImage" runat="server" ClientInstanceName="uploader"
>
<clientsideevents fileuploadcomplete="function(s, e) { Uploader_OnUploadComplete(e); }"
="" fileuploadstart="function(s, e) { Uploader_OnUploadStart(); }">
<validationsettings allowedcontenttypes="image/jpeg,image/gif,image/pjpeg,image/bmp"
="" allowedfileextensions=".jpg,.jpeg,.jpe,.gif,.bmp" maxfilesize="4000000">


</div>
<div style="float: left; width: 45px; vertical-align: baseline;">
<dx:ASPxButton ID="btnUpload" runat="server" AutoPostBack="False" CausesValidation="false"
ClientInstanceName="btnUpload" Text="Upload" ToolTip="Allowed image types: jpeg, gif,bmp and Maximum file size: 4Mb"
TabIndex="9" Width="45px">
<clientsideevents click="function(s, e) { uploader.UploadFile(); }">

</div>

<td rowspan="6">
<img id="previewImage" runat="server" alt="" src="~/Images/user.JPG" style="width: 150px;
height: 150px" />
</td>




<script language="javascript" type="text/javascript">
function Uploader_OnUploadStart() {
//alert("Hi");
btnUpload.SetText("Uploading...");
btnUpload.SetEnabled(false);
}
function Uploader_OnUploadComplete(args) {
var imgSrc = aspxPreviewImgSrc;
if (args.isValid) {
var date = new Date();
imgSrc = '<%=ResolveUrl("~/UploadedImages/") %>' + args.callbackData; //"UploadedImages/" + args.callbackData; //+ "?dx=" + date.getTime();
}
getPreviewImageElement().src = imgSrc;
btnUpload.SetEnabled(true);
btnUpload.SetText("Upload");
}
function getPreviewImageElement() {
return _aspxGetElementById('<%=previewImage.ClientID%>'); //("previewImage");
}
var aspxPreviewImgSrc = (getPreviewImageElement() != null) ? getPreviewImageElement().src : null;
</script>
NIDHIN.C 3-Oct-15 5:10am    
server side code

protected string SavePostedFile(UploadedFile uploadedFile)
{
string ret = "";
if (uploadedFile.IsValid)
{
//String NewFileName = Guid.NewGuid().ToString() + Path.GetExtension(uploadedFile.FileName);
String NewFileName = Session.SessionID + Path.GetExtension(uploadedFile.FileName);
String tempFileName = MapPath(UploadDirectory) + NewFileName;
StoreSessionState(UPLOADEDIMGNAME, tempFileName);
uploadedFile.SaveAs(tempFileName);
ret = NewFileName;
}
return ret;
}
Review your in page load event.
OriginalGriff 3-Oct-15 5:00am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900