Re: enter key hell problem 2

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: gh0st54 (gh0st54_at_hotmail.com)
Date: 09/18/04


Date: 18 Sep 2004 15:40:57 -0700

tried it also

i keep getting send to index.asp

here is my code
please help

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::
:: aspx ::
::::::::::

<%@ Register TagPrefix="uc1" TagName="ad2" Src="ssi/ad2.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ImageInfo"
Src="ssi/ImageInfo.ascx" %>
<%@ Page language="c#" Codebehind="add_photos.aspx.cs"
AutoEventWireup="false" Inherits="[sitename]2.add_photos" %>
<%@ Register TagPrefix="uc1" TagName="header" Src="ssi/header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="footer" Src="ssi/footer.ascx" %>
<%@ Reference Control="ssi/ImageInfo.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>

<meta http-equiv=Content-Type content=text/html;>
<META http-equiv=Refresh content=180><LINK href="css/Topnavbar.css"
type=text/css rel=style*** ><LINK href="css/FormsStyles.css"
type=text/css rel=style*** >
<script language=javascript>
                        <!--
                        function changeimage(){
                                if(document.getElementById("File1").value!=''){
                                document.images["imgToUpload"].src =
document.getElementById("File1").value;}
                        }
                        function OpenUpload(){
                                window.open("upload_pic.aspx","_blank","resizable=0,toolbar=0,menubar=0,height=400,width=375");
                        }
                        
                        //-->
                                </script>

</HEAD>
<body bgColor=#6699cc topMargin=0>
<form id=Form1 method=post runat="server"><input type="text"
style="display:none" ><uc1:header id=Header1
runat="server"></uc1:header>
<table cellSpacing=0 cellPadding=0 width=755 border=0>
  <tr>
    <td class=box_white>
      <table width="99%" align=center border=0>
        <tr>
          <td>
            <table cellSpacing=0 cellPadding=0 width="100%" border=0
>
              <tr>
                <td vAlign=top width="79%">
                  <table cellSpacing=2 cellPadding=2 width="100%"
border=0
>
                    <tr>
                      <td width="5%" bgColor=#0099cc
>&nbsp;</TD>
                      <td class=white_login width="95%"
bgColor=#ffffff
>
                        <table cellSpacing=0 cellPadding=0
width="100%" border=0
>
                          <tr>
                            <td width="51%" height=24><asp:image
id=imgTitle runat="server" AlternateText="Your Photos" Width="200px"
Height="25px"></asp:image></TD>
                            <td class=whitenorm width="49%"
bgColor=#e1f0ff
                            height=24>&nbsp;
                          </TD></TR></TABLE></TD></TR>
                    <tr>
                      <td width="5%" bgColor=#ff6600 height=28
>&nbsp;</TD>
                      <td class=header_oran_14 width="95%"
bgColor=#ffffff
>&nbsp;&nbsp;<A class=header_ora_14nu
href="javascript:OpenUpload();" >Add new
                        Photos</A></TD></TR></TABLE>
                  <table cellSpacing=2 cellPadding=2 width="100%"
                  bgColor=#ffffff border=0>
                    <tr>
                      <td width="5%" bgColor=#e1f0ff
>&nbsp;</TD>
                      <td class=line vAlign=top width="95%"
bgColor=#ffffff
>
                        <table cellSpacing=1 cellPadding=1
width="100%" border=0
>
                          <tr>
                            <td class=footer_large colSpan=2 height=20
>
                              <div class=head_gray align=left
><A class=header href="report"
></A>&nbsp;&nbsp;<span
                              class=header_blue_14nu
>Edit/remove your images
                              below</SPAN></DIV></TD></TR>
                          <tr>
                            <td class=footer_large colSpan=2
>&nbsp;&nbsp; <asp:panel
                              id=pnlImageInfo
                              runat="server"></asp:panel></TD>
                          <tr>
                                                                                                                                        <td class="footer_large" colSpan="2">
                                                                                                                                                <!--table cellSpacing="2" cellPadding="2"
width="100%" border="0">
                                                                                                                                                        <tr>
                                                                                                                                                                <td width="34%" rowspan="3">
                                                                                                                                                                        
                                                                                                                                                                </td>
                                                                                                                                                                <td width="33%">
                                                                                                                                                                        <div align="center"><IMG class="line_total"
height="84" src="images/default_picture.gif" width="81"></div>
                                                                                                                                                                </td>
                                                                                                                                                                <td width="33%">
                                                                                                                                                                        <div align="center"><IMG class="line_total"
height="84" src="images/default_picture.gif" width="81"></div>
                                                                                                                                                                </td>
                                                                                                                                                        </tr>
                                                                                                                                                        <tr>
                                                                                                                                                                <td class="header" width="34%">
                                                                                                                                                                        <table height="22" cellSpacing="0"
cellPadding="0" width="90%" align="center" border="0">
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="radio"
value="radiobutton" name="radiobutton">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Set image as
default</td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%">&nbsp;</td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Image -
Public Content</td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="checkbox"
value="checkbox" name="checkbox24">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">change to
                                                                                                                                                                                                <span class="header_orange_10">Adult
                                Content</span></td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="checkbox"
value="checkbox" name="checkbox">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Remove Image
                                                                                                                                                                                        </td>
                                                                                                                                                                                </tr>
                                                                                                                                                                        </table>
                                                                                                                                                                </td>
                                                                                                                                                                <td class="header" width="33%">
                                                                                                                                                                        <table height="22" cellSpacing="0"
cellPadding="0" width="94%" align="center" border="0">
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="radio"
value="radiobutton" name="radiobutton">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Set image as
default</td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%">&nbsp;</td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Image -
                                                                                                                                                                                                <span class="header_orange_10">Adult
                                Content</span></td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="checkbox"
value="checkbox" name="checkbox22">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">change to
                                                                                                                                                                                                <span class="header">Public
                                Content</span></td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="checkbox"
value="checkbox" name="checkbox2">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Remove Image
                                                                                                                                                                                        </td>
                                                                                                                                                                                </tr>
                                                                                                                                                                        </table>
                                                                                                                                                                </td>
                                                                                                                                                                <td class="header" width="33%">
                                                                                                                                                                        <table height="22" cellSpacing="0"
cellPadding="0" width="98%" align="center" border="0">
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="radio"
value="radiobutton" name="radiobutton">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Set image as
default</td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%">&nbsp;</td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Image -
Public Content</td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="checkbox"
value="checkbox" name="checkbox23">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">change to
                                                                                                                                                                                                <span class="header_orange_10">Adult
                                Content</span></td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="checkbox"
value="checkbox" name="checkbox3">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Remove Image
                                                                                                                                                                                        </td>
                                                                                                                                                                                </tr>
                                                                                                                                                                        </table>
                                                                                                                                                                </td>
                                                                                                                                                        </tr>
                                                                                                                                                        <tr>
                                                                                                                                                                <td class="header" width="34%">
                                                                                                                                                                        <div align="center"><input style="BORDER-RIGHT:
#396181 1px solid; BORDER-TOP: #396181 1px solid; FONT-SIZE: 11px;
BORDER-LEFT: #396181 1px solid; COLOR: #396181; LINE-HEIGHT: 11px;
BORDER-BOTTOM: #396181 1px solid; FONT-FAMILY: Tahoma;
BACKGROUND-COLOR: #ffffff"
                                                                                                                                                                                        maxLength="30" size="20" value=" Brief
Description" name="mem_worst_mom2" likley>
                                                                                                                                                                        </div>
                                                                                                                                                                </td>
                                                                                                                                                                <td class="header" width="33%">
                                                                                                                                                                        <div align="center"><input style="BORDER-RIGHT:
#396181 1px solid; BORDER-TOP: #396181 1px solid; FONT-SIZE: 11px;
BORDER-LEFT: #396181 1px solid; COLOR: #396181; LINE-HEIGHT: 11px;
BORDER-BOTTOM: #396181 1px solid; FONT-FAMILY: Tahoma;
BACKGROUND-COLOR: #ffffff"
                                                                                                                                                                                        maxLength="30" size="20" value=" Brief
Description" name="mem_worst_mom22" likley>
                                                                                                                                                                        </div>
                                                                                                                                                                </td>
                                                                                                                                                                <td class="header" width="33%">
                                                                                                                                                                        <div align="center"><input style="BORDER-RIGHT:
#396181 1px solid; BORDER-TOP: #396181 1px solid; FONT-SIZE: 11px;
BORDER-LEFT: #396181 1px solid; COLOR: #396181; LINE-HEIGHT: 11px;
BORDER-BOTTOM: #396181 1px solid; FONT-FAMILY: Tahoma;
BACKGROUND-COLOR: #ffffff"
                                                                                                                                                                                        maxLength="30" size="20" value=" Brief
Description" name="mem_worst_mom23" likley>
                                                                                                                                                                        </div>
                                                                                                                                                                </td>
                                                                                                                                                        </tr>
                                                                                                                                                </table--></td></TR>
                                                                                                                                <!--tr>
                                                                                                                                        <td class="footer_large" colSpan="2">
                                                                                                                                                <table cellSpacing="2" cellPadding="2" width="100%"
border="0">
                                                                                                                                                        <tr>
                                                                                                                                                                <td width="34%">
                                                                                                                                                                        <div align="center"><IMG class="line_total"
height="84" src="images/default_picture.gif" width="81"></div>
                                                                                                                                                                </td>
                                                                                                                                                                <td width="33%">
                                                                                                                                                                        <div align="center"><IMG class="line_total"
height="84" src="images/default_picture.gif" width="81"></div>
                                                                                                                                                                </td>
                                                                                                                                                                <td width="33%">
                                                                                                                                                                        <div align="center"><IMG class="line_total"
height="84" src="images/default_picture.gif" width="81"></div>
                                                                                                                                                                </td>
                                                                                                                                                        </tr>
                                                                                                                                                        <tr>
                                                                                                                                                                <td class="header" width="34%">
                                                                                                                                                                        <table height="22" cellSpacing="0"
cellPadding="0" width="90%" align="center" border="0">
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="radio" CHECKED
value="radiobutton" name="radiobutton">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Set image as
default</td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%">&nbsp;</td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Image -
Public Content</td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="checkbox"
value="checkbox" name="checkbox24">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">change to
                                                                                                                                                                                                <span class="header_orange_10">Adult
                                Content</span></td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="checkbox"
value="checkbox" name="checkbox">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Remove Image
                                                                                                                                                                                        </td>
                                                                                                                                                                                </tr>
                                                                                                                                                                        </table>
                                                                                                                                                                </td>
                                                                                                                                                                <td class="header" width="33%">
                                                                                                                                                                        <table height="22" cellSpacing="0"
cellPadding="0" width="94%" align="center" border="0">
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="radio"
value="radiobutton" name="radiobutton">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Set image as
default</td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%">&nbsp;</td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Image -
                                                                                                                                                                                                <span class="header_orange_10">Adult
                                Content</span></td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="checkbox"
value="checkbox" name="checkbox22">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">change to
                                                                                                                                                                                                <span class="header">Public
                                Content</span></td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="checkbox"
value="checkbox" name="checkbox2">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Remove Image
                                                                                                                                                                                        </td>
                                                                                                                                                                                </tr>
                                                                                                                                                                        </table>
                                                                                                                                                                </td>
                                                                                                                                                                <td class="header" width="33%">
                                                                                                                                                                        <table height="22" cellSpacing="0"
cellPadding="0" width="98%" align="center" border="0">
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="radio"
value="radiobutton" name="radiobutton">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Set image as
default</td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%">&nbsp;</td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Image -
Public Content</td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="checkbox"
value="checkbox" name="checkbox23">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">change to
                                                                                                                                                                                                <span class="header_orange_10">Adult
                                Content</span></td>
                                                                                                                                                                                </tr>
                                                                                                                                                                                <tr>
                                                                                                                                                                                        <td width="22%"><input type="checkbox"
value="checkbox" name="checkbox3">
                                                                                                                                                                                        </td>
                                                                                                                                                                                        <td class="head_gray" width="78%">Remove Image
                                                                                                                                                                                        </td>
                                                                                                                                                                                </tr>
                                                                                                                                                                        </table>
                                                                                                                                                                </td>
                                                                                                                                                        </tr>
                                                                                                                                                        <tr>
                                                                                                                                                                <td class="header" width="34%">
                                                                                                                                                                        <div align="center"><input style="BORDER-RIGHT:
#396181 1px solid; BORDER-TOP: #396181 1px solid; FONT-SIZE: 11px;
BORDER-LEFT: #396181 1px solid; COLOR: #396181; LINE-HEIGHT: 11px;
BORDER-BOTTOM: #396181 1px solid; FONT-FAMILY: Tahoma;
BACKGROUND-COLOR: #ffffff"
                                                                                                                                                                                        maxLength="30" size="20" value=" Brief
Description" name="mem_worst_mom2" likley>
                                                                                                                                                                        </div>
                                                                                                                                                                </td>
                                                                                                                                                                <td class="header" width="33%">
                                                                                                                                                                        <div align="center"><input style="BORDER-RIGHT:
#396181 1px solid; BORDER-TOP: #396181 1px solid; FONT-SIZE: 11px;
BORDER-LEFT: #396181 1px solid; COLOR: #396181; LINE-HEIGHT: 11px;
BORDER-BOTTOM: #396181 1px solid; FONT-FAMILY: Tahoma;
BACKGROUND-COLOR: #ffffff"
                                                                                                                                                                                        maxLength="30" size="20" value=" Brief
Description" name="mem_worst_mom22" likley>
                                                                                                                                                                        </div>
                                                                                                                                                                </td>
                                                                                                                                                                <td class="header" width="33%">
                                                                                                                                                                        <div align="center"><input style="BORDER-RIGHT:
#396181 1px solid; BORDER-TOP: #396181 1px solid; FONT-SIZE: 11px;
BORDER-LEFT: #396181 1px solid; COLOR: #396181; LINE-HEIGHT: 11px;
BORDER-BOTTOM: #396181 1px solid; FONT-FAMILY: Tahoma;
BACKGROUND-COLOR: #ffffff"
                                                                                                                                                                                        maxLength="30" size="20" value=" Brief
Description" name="mem_worst_mom23" likley>
                                                                                                                                                                        </div>
                                                                                                                                                                </td>
                                                                                                                                                        </tr>
                                                                                                                                                </table>
                                                                                                                                        </td>
                                                                                                                                </tr-->
                          <tr>
                            <td class=footer_large colSpan=2
>
                              <div class=head_gray align=right
>Click save to update all
                             
additions/changes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:imagebutton id=btnSave
runat="server"></asp:imagebutton>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                             
</DIV></TD></TR></TABLE></TD></TR></TABLE></TD>
                <td vAlign=top width="21%" bgColor=#ffffff
><div align=right><uc1:ad2 id=Ad21
runat="server"></uc1:ad2></DIV></TD></TR></TABLE></TD></TR></TABLE></TD></TR></TABLE>
                        <uc1:footer id="Footer1"
runat="server"></uc1:footer></FORM></CC1:IR>
        </body>
</HTML>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::
:: C# ::
::::::::

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.IO;
using Members.ssi;

namespace [sitename]2
{
        /// <summary>
        /// Summary description for add_photos.
        /// </summary>
        public class add_photos : System.Web.UI.Page
        {
                protected System.Web.UI.WebControls.Image imgTitle;
                protected System.Web.UI.WebControls.ImageButton btnSave;
                protected System.Data.SqlClient.SqlConnection cnn;
                protected System.Data.SqlClient.SqlCommand ssp_GetMyPictures;
                protected System.Data.SqlClient.SqlCommand ssp_DeleteImageInfo;
                protected System.Data.SqlClient.SqlCommand ssp_UpdateImageInfo;
                protected System.Web.UI.WebControls.Panel pnlImageInfo;
                protected Int32 node=1;
                protected System.Data.SqlClient.SqlConnection sqlConnection1;
                protected Control imgInfo;
                
                private void Page_Load(object sender, System.EventArgs e)
                {
                        if(Session["MemberId"]==null){Response.Redirect(ConfigurationSettings.AppSettings["rootPath"].ToString()+"/members/login.aspx",true);}
                        if(!Page.IsPostBack){
                                this.imgTitle.ImageUrl =
ConfigurationSettings.AppSettings["ImgPath"]+"your_photos.gif";
                                this.btnSave.ImageUrl =
ConfigurationSettings.AppSettings["ImgPath"]+"save.gif";
                                Page.RegisterHiddenField("__EVENTTARGET", this.btnSave.ClientID );
                        }
                        this.GetImages();
                        

                }

                #region Web Form Designer generated code
                override protected void OnInit(EventArgs e)
                {
                        //
                        // CODEGEN: This call is required by the ASP.NET Web Form Designer.
                        //
                        InitializeComponent();
                        base.OnInit(e);
                }
                
                /// <summary>
                /// Required method for Designer support - do not modify
                /// the contents of this method with the code editor.
                /// </summary>
                private void InitializeComponent(){
                   
                        this.cnn = new System.Data.SqlClient.SqlConnection();
                        this.ssp_GetMyPictures = new System.Data.SqlClient.SqlCommand();
                        this.btnSave.Click += new
System.Web.UI.ImageClickEventHandler(this.btnSave_Click);
                        this.ssp_UpdateImageInfo = new System.Data.SqlClient.SqlCommand();
                        this.ssp_DeleteImageInfo = new System.Data.SqlClient.SqlCommand();
                        //
                        // cnn
                        //
                        this.cnn.ConnectionString =
ConfigurationSettings.AppSettings["cnn"].ToString();
                        //
                        // ssp_GetMyPictures
                        //
                        this.ssp_GetMyPictures.CommandText = "dbo.[ssp_GetMyPictures]";
                        this.ssp_GetMyPictures.CommandType =
System.Data.CommandType.StoredProcedure;
                        this.ssp_GetMyPictures.Connection = this.cnn;
                        this.ssp_GetMyPictures.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)),
((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
                        this.ssp_GetMyPictures.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@MemberId",
System.Data.SqlDbType.UniqueIdentifier, 16));
                        this.ssp_GetMyPictures.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@ErrorMessage",
System.Data.SqlDbType.NVarChar, 50,
System.Data.ParameterDirection.Output, false, ((System.Byte)(0)),
((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
                        this.ssp_GetMyPictures.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Error",
System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Output,
false, ((System.Byte)(0)), ((System.Byte)(0)), "",
System.Data.DataRowVersion.Current, null));
                        //
                        // ssp_DeleteImageInfo
                        //
                        this.ssp_DeleteImageInfo.CommandText = "dbo.[ssp_DeleteImageInfo]";
                        this.ssp_DeleteImageInfo.CommandType =
System.Data.CommandType.StoredProcedure;
                        this.ssp_DeleteImageInfo.Connection = this.cnn;
                        this.ssp_DeleteImageInfo.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@MemberId",
System.Data.SqlDbType.UniqueIdentifier, 16));
                        this.ssp_DeleteImageInfo.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@ImageName",
System.Data.SqlDbType.NVarChar, 50));
                        this.ssp_DeleteImageInfo.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Error",
System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Output,
false, ((System.Byte)(0)), ((System.Byte)(0)), "",
System.Data.DataRowVersion.Current, null));
                        //
                        // ssp_UpdateImageInfo
                        //
                        this.ssp_UpdateImageInfo.CommandText = "dbo.[ssp_UpdateImageInfo]";
                        this.ssp_UpdateImageInfo.CommandType =
System.Data.CommandType.StoredProcedure;
                        this.ssp_UpdateImageInfo.Connection = this.cnn;
                        this.ssp_UpdateImageInfo.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@MemberId",
System.Data.SqlDbType.UniqueIdentifier, 16));
                        this.ssp_UpdateImageInfo.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@ImageName",
System.Data.SqlDbType.NVarChar, 50));
                        this.ssp_UpdateImageInfo.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Default",
System.Data.SqlDbType.Bit,1));
                        this.ssp_UpdateImageInfo.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Adult",
System.Data.SqlDbType.Bit, 1));
                        this.ssp_UpdateImageInfo.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Description",
System.Data.SqlDbType.NVarChar, 40));
                        this.ssp_UpdateImageInfo.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Error",
System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Output,
false, ((System.Byte)(0)), ((System.Byte)(0)), "",
System.Data.DataRowVersion.Current, null));
                        
                        this.Load += new System.EventHandler(this.Page_Load);

                }
                #endregion

                private void GetImages(){
                        System.Web.UI.WebControls.Table Maintb = new Table();
                        System.Web.UI.WebControls.Table imgTable;// = new Table();
                        System.Web.UI.WebControls.TableRow Maintr = new TableRow();
                        System.Web.UI.WebControls.TableRow imgtr;// = new TableRow();
                        System.Web.UI.WebControls.TableCell Maintd = new TableCell();
                        System.Web.UI.WebControls.TableCell imgtd;// = new TableCell();
                        //int node=1;
                        System.Web.UI.WebControls.TextBox txt;
                        System.Web.UI.WebControls.CheckBox chk;
                        System.Web.UI.HtmlControls.HtmlImage img;
                        System.Web.UI.WebControls.RadioButton rad;
                        
                        DataSet ds =this.CreateData();
                        #region table_creation
                        if(ds.Tables[0].Rows.Count>0){
                                foreach(DataRow dr in ds.Tables[0].Rows){
                                        
                                        //imgInfo = LoadControl("ssi/ImageInfo.ascx");// new ImageInfo();
                                        //((ImageInfo)imgInfo).imgPicture.ImageUrl
=ConfigurationSettings.AppSettings["MembersImgPath"]+
dr["ImageName"].ToString();
                                        //((ImageInfo)imgInfo).txtDescription.Text =
        dr["Description"].ToString();
                                        //((ImageInfo)imgInfo).chkDefault.Checked =
Convert.ToBoolean(dr["default"].ToString());
                                        //((ImageInfo)imgInfo).chkPublic.Checked =
!Convert.ToBoolean(dr["adult"].ToString());
                                        //((ImageInfo)imgInfo).ID = "ImageInfo" + node.ToString();
                                        
                                        imgTable = new Table();
                                        imgTable.Height =22;
                                        imgTable.Width= Unit.Percentage(94);
                                        imgTable.Attributes.Add("align","center");
                                        imgTable.BorderWidth=0;
                                        imgTable.CellPadding=0;
                                                                                                                                                                                                        imgTable.CellSpacing=0;
// image
                                        imgtr = new TableRow();
                                        imgtd = new TableCell();
                                        imgtd.ColumnSpan=2;
                                        imgtd.Controls.Add(new LiteralControl(@"<div
align=""center"">"));
                                        img = new HtmlImage();
                                        img.ID="imgPic"+node.ToString();
                                        img.Height=84 ;
                                        img.Width=81;
                                        img.Src= ConfigurationSettings.AppSettings["MembersImgPath"]+
dr["ImageName"].ToString();
                                        imgtd.Controls.Add(img);
                                        imgtd.Controls.Add(new LiteralControl(@"</div>"));
                                        imgtr.Cells.Add(imgtd);
                                        imgTable.Rows.Add(imgtr);
                                                                                                                                                                
// chk default
                                        imgtr = new TableRow();
                                        imgtd = new TableCell();
                                        imgtd.Width=22;
                                        rad = new RadioButton();
                                        rad.ID="radDef"+node.ToString();
                                        rad.GroupName="Default";
                                        rad.Checked = Convert.ToBoolean(dr["default"].ToString());
                                        imgtd.Controls.Add(rad);
                                        imgtr.Cells.Add(imgtd);
                                        imgtd = new TableCell();
                                        imgtd.Width=78;
                                        imgtd.Text = "Set image as default";
                                        imgtd.CssClass ="head_gray";
                                        imgtr.Cells.Add(imgtd);
                                        imgTable.Rows.Add(imgtr);

// chkStatus
                                        imgtr = new TableRow();
                                        imgtd = new TableCell();
                                        imgtd.Width=22;
                                        chk = new CheckBox();
                                        chk.ID="chkStatus"+node.ToString();
                                        chk.Checked = Convert.ToBoolean(dr["adult"].ToString());
                                        imgtd.Controls.Add(chk);
                                        imgtr.Cells.Add(imgtd);
                                        imgtd = new TableCell();
                                        imgtd.Width=78;
                                        imgtd.Text = "Adult Content";
                                        imgtd.CssClass ="header_orange_10";
                                        imgtr.Cells.Add(imgtd);
                                        imgTable.Rows.Add(imgtr);
// chkDelete
                                        imgtr = new TableRow();
                                        imgtd = new TableCell();
                                        imgtd.Width=22;
                                        chk = new CheckBox();
                                        chk.ID="chkDelete"+node.ToString();
                                        imgtd.Controls.Add(chk);
                                        imgtr.Cells.Add(imgtd);
                                        imgtd = new TableCell();
                                        imgtd.Width=78;
                                        imgtd.Text = "Remove image";
                                        imgtd.CssClass ="head_gray";
                                        imgtr.Cells.Add(imgtd);
                                        imgTable.Rows.Add(imgtr);

// txt Description
                                        imgtr = new TableRow();
                                        imgtd = new TableCell();
                                        imgtd.ColumnSpan=2;
                                        imgtd.Controls.Add(new LiteralControl(@"<center>"));
                                        txt = new TextBox();
                                        txt.ID="txtDescription"+node.ToString();
                                        txt.CssClass="TextBox";
                                        txt.MaxLength=40;
                                        txt.Text= dr["Description"].ToString();
                                        imgtd.Controls.Add(txt);
                                        imgtd.Controls.Add(new LiteralControl(@"</center>"));
                                        imgtr.Cells.Add(imgtd);
                                        imgTable.Rows.Add(imgtr);

                                        Maintd.Controls.Add(imgTable);
                                        
                                        Maintr.Cells.Add(Maintd);
                                                        
                                        if(node%3==0){
                                                Maintb.Rows.Add(Maintr);
                                                Maintr = new TableRow();
                                        }
                                        if(node!=ds.Tables[0].Rows.Count){
                                                Maintd = new TableCell();
                                                node++;
                                        }
                                }
                                if(node%3!=0){
                                        Maintb.Rows.Add(Maintr);
                                }
                                
                                this.pnlImageInfo.Controls.Add(Maintb);
                                #endregion
                        }
                        else {
                                this.pnlImageInfo.Controls.Add(new LiteralControl(@"<div
class=""header"">No Image</div>"));
                        }
                        //this.Controls.Add(imgInfo);
                }
                private DataSet CreateData(){
                        this.ssp_GetMyPictures.Parameters["@MemberId"].Value= new
Guid(Session["MemberId"].ToString());//MemberId;
                        this.ssp_GetMyPictures.Parameters["@Error"].Value= null;
                        
                        SqlDataAdapter daData = new SqlDataAdapter();
                        daData.SelectCommand = this.ssp_GetMyPictures ;

                        DataSet ds = new DataSet();
                                
                        try {
                                this.cnn.Open();
                                daData.Fill(ds);
                                if(Convert.ToBoolean(ssp_GetMyPictures.Parameters["@Error"].Value))
{// si erreur
                                        Session["Status"]=this.ssp_GetMyPictures.Parameters["@ErrorMessage"].Value;
                                        Response.Redirect("add_photos.aspx");
                                }
                        }
                        catch(System.Exception ex){
                                Response.Write(ex.Message);
                        }
                        finally {
                                this.cnn.Close();
                        }
                        return ds;
                }

                private void btnSave_Click(object sender,
System.Web.UI.ImageClickEventArgs e) {
                        this.Save();
                }
                private void Save() {
                        string imgName;
                        string sFile;

                        for(Int32 i=1;i<=node;i++){

                                if( ((System.Web.UI.WebControls.CheckBox)Page.FindControl("Form1").FindControl(this.pnlImageInfo.ID).FindControl("chkDelete"+i.ToString())).Checked==true){
                                        //delete
                                        this.ssp_DeleteImageInfo.Parameters["@MemberId"].Value= new
Guid(Session["MemberId"].ToString());//MemberId;
                                        imgName = ((System.Web.UI.HtmlControls.HtmlImage)Page.FindControl("Form1").FindControl(this.pnlImageInfo.ID).FindControl("imgPic"+i.ToString())).Src;
                                        imgName = imgName.Substring(imgName.Length-40,40);
                                        this.ssp_DeleteImageInfo.Parameters["@ImageName"].Value =
imgName;
                                        this.ssp_DeleteImageInfo.Parameters["@Error"].Value= null;
                                        
                                        try {
                                                this.cnn.Open();
                                                //daData.Fill(ds);
                                                this.ssp_DeleteImageInfo.ExecuteNonQuery();
                                                if(Convert.ToBoolean(ssp_DeleteImageInfo.Parameters["@Error"].Value))
{// si erreur
                                                        Session["Status"]=Session["Status"].ToString() + "Delete
failed for image #"+node.ToString() + "<br>" ;
                                                        Response.Redirect("add_photos.aspx");
                                                }
                                                sFile = Server.MapPath("Images/Members") + "\\" + imgName;
                                                File.Delete(sFile);
                                                
                                        }
                                        catch(System.Exception ex) {
                                                Response.Write(ex.Message);
                                        }
                                        finally {
                                                this.cnn.Close();
                                        }
                                }
                                else{//update
                                        this.ssp_UpdateImageInfo.Parameters["@MemberId"].Value= new
Guid(Session["MemberId"].ToString());//MemberId;
                                        imgName = ((System.Web.UI.HtmlControls.HtmlImage)Page.FindControl("Form1").FindControl(this.pnlImageInfo.ID).FindControl("imgPic"+i.ToString())).Src;
                                        this.ssp_UpdateImageInfo.Parameters["@ImageName"].Value =
imgName.Substring(imgName.Length-40,40);
                                        this.ssp_UpdateImageInfo.Parameters["@Default"].Value =
((System.Web.UI.WebControls.RadioButton)Page.FindControl("Form1").FindControl(this.pnlImageInfo.ID).FindControl("radDef"+i.ToString())).Checked;
                                        this.ssp_UpdateImageInfo.Parameters["@Adult"].Value=((System.Web.UI.WebControls.CheckBox)Page.FindControl("Form1").FindControl(this.pnlImageInfo.ID).FindControl("chkStatus"+i.ToString())).Checked;
                                        this.ssp_UpdateImageInfo.Parameters["@Description"].Value=
((System.Web.UI.WebControls.TextBox)Page.FindControl("Form1").FindControl(this.pnlImageInfo.ID).FindControl("txtDescription"+i.ToString())).Text;
                                        this.ssp_UpdateImageInfo.Parameters["@Error"].Value= null;
                                        
                                        //SqlDataAdapter daData = new SqlDataAdapter();
                                        //daData.SelectCommand = this.ssp_GetMyPictures ;

                                        //DataSet ds = new DataSet();
                                                
                                        try {
                                                this.cnn.Open();
                                                //daData.Fill(ds);
                                                this.ssp_UpdateImageInfo.ExecuteNonQuery();
                                                if(Convert.ToBoolean(ssp_UpdateImageInfo.Parameters["@Error"].Value))
{// si erreur
                                                        Session["Status"]=Session["Status"].ToString() + "Update
failed for image #"+node.ToString() + "<br>" ;
                                                        Response.Redirect("add_photos.aspx");
                                                }
                                                
                                        }
                                        catch(System.Exception ex) {
                                                Response.Write(ex.Message);
                                        }
                                        finally {
                                                this.cnn.Close();
                                        }
                                }
                        }

                        Response.Redirect("add_photos.aspx");
                        //test+="<br>test end";
                        //Response.Write(test);
                }
        }
}


Quantcast