VS 2012 - Loading Images Into Repeater Control
Aug 19, 2013
I'm creating a simple CMS for a fairly simple web page. I'm currently working on a part for displaying news on the main page.
The controls I have on the page:
- a GridView control with enabled pagging and a SELECT button,
- an Image control for displaying news cover picture,
- CKeditor control for editing news text,
- Repeater control for displaying pictures from database
How does it all work?
In Page_load I have the following:
vb.net Code:
connectionString = "Data Source=KORISNIK-PCSQLEXPRESS;Initial Catalog=****;
User ID=**;Password=****" conn = New SqlConnection(connectionString)
If conn.State = ConnectionState.Closed Or conn.State = ConnectionState.Broken Then
Try conn.Open() If Not IsPostBack Then bindGrid()
[Code] ...
As you can see, I load the GridView control with news from DB. At this moment all other control are disabled. User has to SELECT the row he wants to edit, and click the MODIFY button.
This is what happens when user clicks the MODIFY button:
vb.net Code:
Private Function selectForEdit() dsSelectForEdit = New DataSet
captionPicture.ImageUrl = "" enableCommands()
Dim sqlQuery As String
sqlQuery = "SELECT news.newsCaption, news.newsIntro, news.newsCoverPicture, news.newsStatus,
[Code] ....
Basically, I select newsDetails based on newsID. Also, this is where I take the coverPicture from the database using a generic handler.
This is the code for showImage.ashx:
vb.net Code:
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim newsID As Int32 If Not context.Request.QueryString("newsID") Is Nothing Then
newsID = Convert.ToInt32(context.Request.QueryString("newsID")) Else
Throw New ArgumentException("No parameter specified") End If
[Code] ....
This part works fine, as the picture is correctly displayed in the Image control. Now, I also want to load the pictures that are related to the selected news. So, I use this function:
vb.net Code:
Private Function selectNewsPictures() dsSelectPicturesForEdit = New DataSet enableCommands()
Dim sqlQuery As String sqlQuery = "SELECT newsDetailsPictureID,newsDetailsPicture,newsDetailsPictureCaption,newsDetailsPictureDescription FROM newsDetailsPictures WHERE newsID = @newsIDEditing" myCommand = New SqlCommand(sqlQuery, conn) myCommand.Parameters.Add("@newsIDEditing", SqlDbType.Int, 250)
[Code] ....
You can see that I take pictureID's and store them into a List (of integer). That way I can use those integers in showNewsPictures.ashx to display all the pictures.
showNewsPictures.ashx:
vb.net Code:
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim newsID As Int32 If Not context.Request.QueryString("pictureID") Is Nothing Then
newsID = Convert.ToInt32(context.Request.QueryString("pictureID")) Else
Throw New ArgumentException("No parameter specified") End If
[Code] ....
The picture ID's are being sent through pictureRepeater_ItemDataBound:
vb.net Code:
Private Sub pictureRepeater_ItemDataBound(sender As Object, e As RepeaterItemEventArgs)
Handles pictureRepeater.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim ctrl As New Image ctrl = e.Item.FindControl("pictureHolder")
ctrl.Width = 100 ctrl.Height = 100 ctrl.ImageUrl = "~/showNewsPictures.ashx?pictureID=" &
listOfIDs.Item(itemIndex) itemIndex = itemIndex + 1 End If End Sub
THE PROBLEM:
I load the page, select the news, click the MODIFY button and all works well. The news details are loaded, the cover picture is loaded, the repeater pictures are loaded.
I click the cancel button (clears all the commands and disables them) and I get an error saying the DataReader needs to be closed.And I never use one This happens either in showNewsPictures.ashx or showImage.ashx.
In some other scenario, this happens right after I click the MODIFY button.
View 1 Replies
Similar Messages:
Mar 23, 2010
I have a Repeater control that loads instances of a custom control I have built. This repeater looks like this:
<asp:Repeater ID="myRepeater" runat="server" OnLoad="myRepeater_Load">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0">
</HeaderTemplate>
<ItemTemplate>
<tr><td><my:CustomControl ID="myControl" runat="server"
OnLoad="myControl_Load" />
</td></tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
I bind to the Repeater through the myRepeater_Load event handler. My custom control is used to render an item within the Repeater. Because of this, I am trying to set properties on the custom control during the myControl_Load event handler. However, I do not know how to access the current item during the myControl_Load event.
Is there a way I can pass along the current item or access the current item during the myControl_Load event? If so, how?
View 3 Replies
Apr 30, 2013
This is my situation:
I use prettyPhoto to display images from database. The images are displayed in a Repeater control with paging enabled, and with page size set to 3.
Everything works fine, the gallery loads up, I can go through pictures. But, prettyPhoto loads only 3 pictures at a time. So if I get 12 pictures from the database, I get 4 pages. So every time I have to view pictures from Page1, close the gallery, click the Next button that displays Page2 and so on.
I understand that this is happening because I set the PageSize to 3. I'm not sure how to "tell" prettyPhoto that there are actually more photos.
This is how I bind the Repeater to the datasource:
vb.net Code:
Dim Pds1 as New PagedDataSource()Pds1.DataSource = dsPictures.Tables(0).DefaultViewPds1.AllowPaging = TruePds1.CurrentPageIndex = CurrentPage Repeater3.DataSource = Pds1Repeater3.DataBind
This is the HTML for the page that uses the Repeater and gallery:
vb.net Code:
<a href = '<%#DataBinder.Eval(Container, "DataItem.newsPictureURL")%>' rel="prettyPhoto[Repeater3]" title = '<%#DataBinder.Eval(Container, "DataItem.newsPictureCaption")%><img id="icons" src = '<%#DataBinder.Eval(Container, "DataItem.newsPictureLocation")%>' alt = '<%#DataBinder.Eval(Container, "DataItem.newsPictureDesc")%>' />
As you can see, I use rel="prettyPhoto[Repeater3]" where Repeater3 is the name of the gallery, or DataSource.
I know it is hard to figure out anything with out inspecting the prettyPhoto source (jQuery).
View 1 Replies
Oct 24, 2010
I want to implement an image gallery in asp.net/C#. I am using sql server 2008, visual studio 2010 and .NET 4.0.
I have made a webpage and now want to display 6 images as thumbnails (and their names just below the thumbnails) at the center of the page. The format of the display is something like this:
[Code]....
Basic operation is like this:
I pull images from a database and then display them as above as thumbnails. The 1 2 3 Next> are links depending on whether there are more than 6 images pulled from the DB. So basically the numbering 1 2 3 4 Next> is dynamic depending on how many images exist. Can anyone give me a basic overview of how this an be achieved? Should I be using a asp:Repeater or a asp:DataList for this kind of a display?
View 1 Replies
Jun 25, 2010
I recently upgraded from VWD 2008 Express to VWD 2010 Express. A problem has developed in that the website's graphics no longer appear in Design mode, there are "Error Creating Control" error messages that did not exist before, and also debugging errors that did not exist before. (Note: these problems did not exist when I first used VWD 2010; they may have originated with recent automatic Windows updates (I use Vista Home Premium SP2 with IIS 7)). The problem exists if I open the website either as a project file or as a website directory.
View 1 Replies
Jun 23, 2010
I have tried binding images to repeater from one folder called images . But now, I am trying to bind the repeater with different folder's images, based on which menu item is clicked like "Wedding", "Birthday". When "Wedding" is clicked then it repeater should be loaded from Wedding folder's images similarly with "Birthday".
Currently i am using following code to load from single folder.
if
{
Repeater1.DataSource = di.GetFiles();
Repeater1.DataBind();
(!IsPostBack)string imgDir = Server.MapPath("~/images");DirectoryInfo di = new DirectoryInfo(imgDir);
[Code]....
View 3 Replies
Feb 12, 2010
I have an ASP.Net (.Net 2.0) application that creates Crystal Reports (version 11.5) and shows them with CrystalReportViewer control. For some reason the control isn't showing the logo image in the header of the report. It renders the following html
<img width="320" height="76" alt="Imagem" src="CrystalImageHandler.aspx?dynamicimage=cr_tmp_image_e47fba99-96fc-471b-ab11-06fd2212bbdd.png" border="0"/>
I already included the aspnet_client folder in my Virtual Directory in IIS.
View 1 Replies
Feb 3, 2014
I am using a repeater control and i want to use one more repeater control inside the existing repeater control .
Like this:
<asp:Repeater ID="Repeater1" runat="server"> <HeaderTemplate> </HeaderTemplate>
<ItemTemplate>
<!-- start child repeater --> Here I want to use one repater control <!-- end child repeater -->
</ItemTemplate>
</asp:Repeater>
View 1 Replies
May 21, 2010
My images are working fine in local machine but when I publish it in dev server it is not working.
I tried changing the format from jpg to GIF to PNG but still it is not working.
View 4 Replies
Dec 8, 2010
I have a web application that is using SSL. Is there anyway to load external images without the SSL warning dialog?
View 1 Replies
Aug 31, 2014
I have a page where I want to load a lot of images to. Say I have a page of like 50 images 2mb large each and I want them to be displayed on one page. Whats the best way to do that?
Basically what I'm doing right now is loading them from the server and displaying them in image tags. Problem is this crashes the browser. In chrome it will crash, in IE it will bog the computer down and lock it up. I think the browser is running out of memory or something.I'm wondering if I should be using a background worker or a different thread or something.. Is this possible with a web app?
View 2 Replies
Jun 15, 2010
I have a gridview which displays data for all employees and their images (stored in database).
The images take more time to render completely when i click sort or paging or reload.
I'm using httphandler to display image as stream.
Is there a way i can speed up this image loading?
View 1 Replies
May 27, 2010
I'm using Crystal Reports in a Webform inside of an MVC application. Images in the reports are not being displayed, however, on both the ASP.NET Development Server and IIS 7 (on Win7x64).
I know from a number of other questions similar to this that the CrystalImageHandler HTTP Handler is responsible for rendering the image, but I've tried all of the usual solutions to no avail.
So far, I have
Added the following to my appSettings (via http://www.mail-archive.com/bdotnet@groups.msn.com/msg26882.html)
<add key="CrystalImageCleaner-AutoStart" value="true" />
<add key="CrystalImageCleaner-Sleep" value="60000" />
<add key="CrystalImageCleaner-Age" value="120000" />
Added the following httpHandler to system.web/httpHandlers (via http://stackoverflow.com/questions/2253682/crystal-report-viewer-control-isnt-loading-the-images-inside-the-report)
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
Added the following to my Global.asax.cs (via http://stackoverflow.com/questions/2006011/crystal-reports-images-and-asp-net-mvc)
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
and
routes.IgnoreRoute("CrystalImageHandler.aspx");
why the images still 404?
View 1 Replies
Apr 26, 2010
why my images are not displaying/loading when i run ASP.net application with IP Address on server 2003.
View 4 Replies
Sep 20, 2015
Today I deployed my ASP.net project in IIS .It is running successfully but images and css will not display.
View 1 Replies
Jul 26, 2010
I am using .net 3.5 framework and i am using repeater control in my application.I am using link button to display the records.Displaying 9 records in a page.Show all button is there.When i click on show all button(Result of 250 records) then the page is loading and hanging for some time anf then it is displaying the all records.I know the time taken between the server and the browser.But i need to avoid the hanging of the page and the loading time should be reduced.How to solve this issue.If the page contains 9 products then it is loaded quickly.But if it contains lot of images then it's hanged. some of my friends told to use the jquery but i have noo idea regarding jquery so can anyone give an solution for this.Till it's breaking my head.
View 2 Replies
Feb 24, 2011
I had to move an asp.net website from Windows 2003 to another server with Windows 2008. Now when I run the website after setting everything up the images will not load. It is a logo that is in a folder named Images. The file is there along with the folder just like on the other site. Any reason this would not work now? Everything else is working except images. Is there something else I missed in the setup?
View 4 Replies
Feb 12, 2011
mvc musicstore sample application loads cart images using code below. In my application product images are store in database. How to modify this code so that images are loaded from database ?
<ul id="product-list">
<%
{ %>
foreach (var product in Model)<li>
<a href="<%= Url.Action("Details", "Store", new { id = product.Contents }) %>">
<img height="100" width="100" alt="<%= product.Name %>" src="Content/ProductImages/<%= product.Contents %>.jpg" />
<span><%= product.Name %></span>
</a>
</li>
<% } %>
</ul>
View 3 Replies
Oct 14, 2010
I have a set of images which are subjected to display inside a usercontrol(horizontally) but while loading the page the images are displaying vertically. Only after the page completely loaded they are displaying properly. How can I use jQuery to hide the images when the page is loading and display them when the page is fully loaded. Below is the usercontrol code I am using for displaying controls:
[Code]....
View 2 Replies
Dec 7, 2010
I have a website using Telerik controls for ASP.NET. When an AJAX request starts, the Loading Panel (defined in the master page) will display, with a loading image, text, and faded white background color. It works totally fine in Firefox and Chrome, but the background image and text don't display in IE8. All that displays is the white background.LoadingPanel code: Loading ideas why IE8 isn't displaying the images? I've inspected the page source, and they're there in the CSS.
View 3 Replies
Jul 11, 2013
How to display my images which are stored on an ftp location within a datalist.
View 1 Replies
Jul 17, 2015
I am working on URL Rewriting using RegisterRoutes.
its working fine but all css ,js and image not working when i redirect page using URL Rewrite.
my code is in global ascx is below
public static void RegisterRoutes(RouteCollection routeCollection) {
routeCollection.MapPageRoute("RouteForcategory", "Product/{Cat_Id}/{Cat_Name}", "~/ProductDetailss.aspx");
}
My image path is
<img src="images/logo.png" alt="logo">
But when i run then url and image path looking like below
http://localhost:49936/Product/3/Fruits
And my image path looked
http://localhost:49936/Product/3/images/logo.png
but above is not correct path .
When I redirect page from home page to Productdetailss.aspx then images css, directory root path are changed and its also rewrite. I dont want to rewrite css,js,and image path .
I am also used resloved url code but not working .
View 1 Replies
Jun 5, 2013
I want to know if it's possible to return the identity value after an insert working with just the insertCommand and the insert parameters - something like this (but this isn't working):
Code:
<asp:SqlDataSource ID="sqlCustomerInformation" runat="server" ConnectionString="<%$ ConnectionStrings:SloanLEDLightingSystemsQuoteToolConnectionString %>"
SelectCommand="SELECT quoteCustomerInformationId,contactname FROM QuoteCustomerInformation order by quoteCustomerInformationId"
[Code] ....
Not sure what's wrong with my code. Should I be doing this in the code behind? I'm also confused as to how I would then retrieve the identity value in the code behind - on iteminserted.
View 2 Replies
Jul 21, 2013
I have a web app connected to a database. I have a ajax tab control on the page with a textbox and a button in a panel that will update the database with whatever the user types in the textbox. But I cant seem to get the behind code to work, I assume the button is not firing.
HTML Code:
<asp:ScriptManager ID="ScriptManager2" runat="server"></asp:ScriptManager>
<ajaxToolkit:TabContainer ID="TabContainer2" runat="server">
<ajaxToolkit:TabPanel>
<asp:TextBox ID="name" runat="server"></asp:TextBox>
<asp:Button ID="updater" runat="server" Text="Button" />
[Code] ......
The code did work without the ajax tab control...
View 8 Replies
Feb 10, 2011
I want to display images by using repeater control. those images have to change with respect each 5seconds. how to change those images? those images should be in database? i kept images in my project folder. then now how to go further.
View 1 Replies