TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aktham Mahmoud
NA
720
37.5k
Access to control in Detailsview By Javascript
Dec 25 2019 6:06 AM
Greeting All I Used Detailsview Control to insert form data. In DetailsView has upoladfile control to upload image. I used JavaScript method to show image before upload it. Like that example [https://www.youtube.com/watch?v=DX3ZoZZ1se8][1]
If apply same example without Detailsview everything good.
Problem: If apply same javascript on uploadfile in detilsview cant work: that's code below:
<script type=
"text/javascript"
>
function
ImagePreview(input) {
if
(input.files && input.files[0]) {
var
reader =
new
FileReader();
reader.onload =
function
(e) {
$(
'<%# ((DV_AddEmployee).FindFieldTemplate("Photo").FindControl("Image1")).ClientID %>'
).prop(
'src'
, e.target.result)
.width(90)
.height(90);
};
reader.readAsDataURL(input.files[0]);
}
}
</script>
and that's id DetilsView code:
<asp:DetailsView ID=
"DV_Add"
runat=
"server"
Height=
"50%"
Width=
"50%"
DefaultMode=
"Insert"
AutoGenerateRows=
"False"
DataKeyNames=
"Id"
OnItemCommand=
"DV_Add_ItemCommand"
>
<Fields>
<asp:TemplateField HeaderText=
"Photo:"
>
<InsertItemTemplate>
<asp:FileUpload ID=
"FileUpload1"
runat=
"server"
onchange=
"ImagePreview(this)"
/>
<asp:Image ID=
"Image1"
runat=
"server"
/>
<br />
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<InsertItemTemplate>
<asp:Button ID=
"BtnInsert"
runat=
"server"
Text=
"Insert"
CommandName=
"AddNew"
/>
<asp:Button ID=
"Btncancel"
runat=
"server"
Text=
"Cancel"
CommandName=
"Cancel"
/>
</InsertItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
<asp:DetailsView ID=
"DV_Add"
runat=
"server"
Height=
"50%"
Width=
"50%"
DefaultMode=
"Insert"
AutoGenerateRows=
"False"
DataKeyNames=
"Id"
OnItemCommand=
"DV_Add_ItemCommand"
> <Fields> <asp:TemplateField HeaderText=
"Photo:"
> <InsertItemTemplate> <asp:FileUpload ID=
"FileUpload1"
runat=
"server"
onchange=
"ImagePreview(this)"
/> <asp:Image ID=
"Image1"
runat=
"server"
/> <br /> </InsertItemTemplate> </asp:TemplateField> <asp:TemplateField> <InsertItemTemplate> <asp:Button ID=
"BtnInsert"
runat=
"server"
Text=
"Insert"
CommandName=
"AddNew"
/> <asp:Button ID=
"Btncancel"
runat=
"server"
Text=
"Cancel"
CommandName=
"Cancel"
/> </InsertItemTemplate> </asp:TemplateField> </Fields> </asp:DetailsView>
Am trying many ways to access to controls image in detailsview (template)(row) no way..
Thanks or help
Reply
Answers (
3
)
Issue With WebService in asp.net?
Stored cross-site scripting Prevention