Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to add a slideshow to my gallery page but i have an error, i couldn't know what is the problem:

here is my code:
XML
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Gallery.aspx.cs" Inherits="Gallery" %>


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
 <%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Collections" %>


<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<p>Gallery</p>
  <script runat="Server" type="text/C#">

        [System.Web.Services.WebMethod]
        [System.Web.Script.Services.ScriptMethod]


        public static AjaxControlToolkit.Slide[] GetSlides()
        {
            //find the file of image
            DirectoryInfo Folder;
            Folder = new DirectoryInfo("~/Scripts");
            int Len;
            Len = Folder.GetFiles().Length;

            AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[Len];
            FileInfo[] Images;
            List<String> imagesList = new List<String>();
            Images = Folder.GetFiles();

            for (int i = 0; i < Len; i++)
            {
                slides[i] = new AjaxControlToolkit.Slide("Scripts/" + Images[i].Name + "", "First image of my album", "First Image");
            }
            return (slides);
        }

    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
 <form id="form1" runat="server">
    <table width="400px" align="center" height="350px" bgcolor="silver">
        <tr align="center">
            <td>
                <asp:ScriptManager ID="ScriptManager2" runat="server" />
                <asp:Label ID="lableImageDetail" runat="server" ForeColor="#000000" />
            </td>
        </tr>
        <tr align="center">
            <td>
                <asp:Image runat="server" ImageUrl="~/Scripts/EmpireImage1.png" ID="image1" Height="250"
                    Width="300" />
            </td>
        </tr>
        <tr align="center">
            <td>
                <asp:Button ID="buttonPrev" runat="Server" Text="Previous" Width="80px" />
                <asp:Button ID="buttonPlay" runat="server" Text="Play" Width="80px" />
                <asp:Button ID="buttonNext" runat="Server" Text="Next" Width="80px" />
            </td>
        </tr>
    </table>
    <cc1:SlideShowExtender ID="slideShowExtender1" runat="Server" TargetControlID="image1"
        ImageDescriptionLabelID="lableImageDetail" Loop="true" AutoPlay="true" StopButtonText="Stop"
        PlayButtonText="Play" NextButtonID="buttonNext" PreviousButtonID="buttonPrev"
        PlayButtonID="buttonPlay" SlideShowServiceMethod="GetSlides" />
    </form>

</asp:Content>




and this is the error:

Server Error in '/EmpireClinicWebsite' Application.
A page can have only one server-side Form tag.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: A page can have only one server-side Form tag.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): A page can have only one server-side Form tag.]
   System.Web.UI.Page.OnFormRender() +9048900
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +36
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +31
   System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +53
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +173
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +31
   System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +53
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
   System.Web.UI.Page.Render(HtmlTextWriter writer) +29
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3060

need help as soon as posible, thanks :)
Posted
Updated 15-Apr-13 7:45am
v2
Comments
Prasad Khandekar 15-Apr-13 11:51am    
The error says it A page can have only one server-side Form tag. Check if your master page also contains a form declaration.
ZurdoDev 15-Apr-13 12:09pm    
Your master page has a form in it and so does one of your contents.
Lili Tanios 16-Apr-13 13:51pm    
thanks Raj, u r right the error is solved, thank u so much for ur help but i have another question is their another way to get images other thank this: DirectoryInfo Folder; Folder = new DirectoryInfo("C:/Users/LiliTanios/Desktop/EmpireImages"); because this will not work when i will post it online. thank u soo much for ur hepl :)
ZurdoDev 16-Apr-13 13:54pm    
In the web you use Server.MapPath.

1 solution

C#
Exception Details: System.Web.HttpException: A page can have only one server-side Form tag.



This line clearly says that you have extra form tag which means your master page already has a form tag so you can't declare another form inside content place holder so simly remove the following line from your code and the error must go off

<form id="form1" runat="server">


just simply remove the form tag completely and you are done

Hope it helps you.....
 
Share this answer
 
Comments
Lili Tanios 16-Apr-13 0:46am    
thanks Raj, u r right the error is solved, thank u so much for ur help
but i have another question is their another way to get images other thank this:
DirectoryInfo Folder;
Folder = new DirectoryInfo("C:/Users/LiliTanios/Desktop/EmpireImages");
because this will not work when i will post it online.
thank u soo much for ur hepl :)

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