Add Browse button in dynamically created view - Entity Framework - asp.net

In my model I want to add a string property that will save the url/path of an image. For that I need to add "Browse" button next to a textbox for the user to select file & also a Image to display the selected image.
How can I save this image somewhere else and not in the DB - as that will increase the size of DB and save time for transferring image from byte[] to file & vice-versa ? Like this, through out the project, I will have many images to upload & show. Right now I am on local DB, Is this possible to achieve, if so, how?
The view file where I want to add browse & Image is like this:
<asp:DynamicControl Mode="Insert" DataField="PANNumber" runat="server" />
it's inside <InsertItemTemplate> <fieldset> & <Validate-Summary>
The view is created by scaffolding.

Related

Copy images from imagefield

I currently have a pdf that contains imagefields.
The issue however is that we want to be able to copy the images users input into the pdf.
Is there a way to alter the imagefield or add a button to the form that will copy the image so it will be available for pasting?
I see that I can put a button on the page and via script access the value for ImageField1.value so I can set it. But how can I read it?
you can access the image data by ".rawValue" attribute.
For example with a button and "click" event.
FormCalc: $.parent.sPic.rawValue = $.parent.dPic.rawValue
JavScript: xfa.resolveNode("sPic").rawValue = xfa.resolveNode("dPic").rawValue
with dPic being imagefield and sPic being image. This script will copy the image from imagefield into the image.

Cannot edit images inside sitecore field renderer

I have used Sitecore field renderer for one of my page to be edited in the Sitecore page editor. That page includes an image which needs to be reference from Sitecore media library.
So I insert the image control into the markup of the Sitecore field renderer as follows
<img id="imgBusinessAdFeatues" class="classifiedImageSamples" src="~/media/Images/What is a Business Account/businessAdFeatures.ashx" alt="Business Ad with Features" />
“~/media/Images/What is a Business Account/businessAdFeatures.ashx” is the path to the image that stored in Sitecore media folder.
Now the image is rendered properly inside the page, but when I tried to edit that image (upload a new image) using Sitecore page editor it’s not allow me.
Is there any way to make the image editable (Upload a new image) when I open that page in Sitecore page editor?
Thanks
Thank you for the ideas.
But my problem is little bit different. I have Sitecore field renderer in in my sample page.
<sc:FieldRenderer ID="frTestPage" runat="server" />
From the code behind on that page, I bind a Sitecore item as follows.
frTestPage.Item = DatabaseManager.MasterDatabase.GetItem(“itemID1”);
frTestPage.FieldName = "Content";
In the item that I’m binding to the field renderer, it has richtextbox field name “Content”.
Within that “Content” field I have inserted my markup to be render to the page. So that markup consist of following img tag and other relevant HTML.
<img id="imgBusinessAdFeatues" class="classifiedImageSamples" src="~/media/Images/What is a Business Account/businessAdFeatures.ashx" alt="Business Ad with Features" />
So how can I give the image src path correctly which reference to an image in Sitecore media library.
It's wrong to use hardcoded path for images:
You can see all parameters here.
If you use XSLT to render your images, you can apply the parameters on the sc:image directly:
<sc:image field="MyImage" width="150" height="100" bc="ffffff"/>
If you use UserControls (.ascx) to render your images, you can register the following tagprefix to access sc:Image and sc:FieldRenderer:
<%# Register TagPrefix="sc" Namespace="Sitecore.Web.UI.WebControls" Assembly="Sitecore.Kernel" %>
You can use Edit(Page Editor), then More -> Insert Image, see:
Also, to have a more edit options you can use "Edit e related Item"

How to take image source from code behind after updating it from client side

I have the following scenario.
User is trying to update the profile image , I am using uploadify plugin to upload image to server , and in callback I am setting
<img src="" runat="server" class="user-image" id="uploadedImage" />
SRC attribute to the uploaded path. This part is working good , then when user clicks on Save button , i need somehow to get new picture path and save it to database.
user.ImageUrl = this.uploadedImage.Attributes["src"];
doen't brings a new picture path , and returns a previous path.
Can someone help pls ?
If you want to accomplish this you may use using hidden field, among other ways.
Please refer to: http://www.codeproject.com/Articles/603102/Persist-JavaScript-changes-on-postback,http://forums.asp.net/t/1428896.aspx/1,http://forums.asp.net/t/1285473.aspx.

How to save image Formed in Response.Write

Hi Iam generating an image using Response.Write in a web page, I want to save the image generated in a folder, help me doing it please.
Response.Write("<img src='image/Black.gif'>")
`Dim Image As String Image="" For i=0 to 10
Image=Image &""
Next Response.Write(Image) `
An image will be displayed using this code, now the question is I want to save that as a single image in my folder(server side)
use a fileupload control
//Get Filename from fileupload control
string filename = Path.GetFileName(fileuploadimages.PostedFile.FileName);
//Save images into Images folder
fileuploadimages.SaveAs(Server.MapPath("Images/"+filename));
if your image generated is a stream use Image class to convert it
Image.FromStream(yourstream);
to save it without upload control:
Image.Save(Server.MapPath("Images/"+filename"));
`Dim Image As String
Image=""
For i=0 to 10
Image=Image &""
Next
Response.Write(Image)
`
An image will be displayed using this code, now the question is I want to save that as a single image in my folder(server side)

how to bind an thumbnail image in repeater control

I have an requirement where in my datatable.
I have 3 columns.
serverpath,image name, id
Now I need to get the imagepath from that the datatable[serverpath] and bind it in a repeater control or gridview control and show the thumbnail images there. Actaully in the path d:/application/images folder I have images.
When I bind to repeater control or grid control I need to convert the orignal images into thumbnail and display in reater control. In (5x5) rows x columns but I need to show only thumbnail images no other details like[server path,id].
ex:
thumailimge1 thumailimge2 thumailimge3 thumailimge4 thumailimge5
thumailimge6 thumailimge7 thumailimge8 thumailimge9 thumailimge10
so once the user click on this thumbnail orignal image will be displayed in a new window
hope my question is clear...
how can I achieve this functionality?
any help would be greatly appreciated
You could write a custom asp.net handler (or even a plain aspx page where you manually write to the Response) to serve the image as the source for an img tag in your repeater
ASHX:
http://www.codeproject.com/KB/aspnet/CustomImageHandler.aspx
http://dotnetperls.com/ashx-handler
ASPX:
http://weblogs.asp.net/whaggard/archive/2003/03/23/4180.aspx
http://www.devx.com/vb2themax/Tip/19463

Resources