Welcome Guest Search | Active Topics | Sign In | Register

Problems with controls in AJAXUploader Options
Sarge
Posted: Tuesday, September 18, 2007 7:19:59 AM

Rank: Member
Groups: Member

Joined: 9/14/2007
Posts: 21
1. I'm having troubles referencing nested controls.
I have a dialog, inside that dialog is an AJAXUploader, inside the LayoutTemplate of the AJAXUploader are my controls. This nesting is necessary to put the AJAXUploader save button where I want it.
I have a handle to the AJAXUploader, retrieved like this.
Code: C#
AJAXUploader fuFiles = (AJAXUploader)dlgFileEditor.ContentContainer.FindControl("fuFiles");

where fuFiles is the name of the AJAXUploader and dlgFileEditor is the name of the dialog control.
That works fine, now I need to get access to the text box's and whatnot inside the AJAXUploader, I would have thought that
Code: C#
TextBox tbxFileTitle = (TextBox)fuFiles.FindControl("tbxFileTitle");

would work, since fuFiles now points to the actual ajax uploader, but it does not.
Also, TextBox tbxFileTitle = (TextBox)dlgFileEditor.ContentContainer.FindControl("tbxFileTitle"); does not work.
neither does
TextBox tbxFileTitle = (TextBox)fuFiles.TemplateControl.FindControl("tbxFileTitle");
Any ideas.

2. I have a drop down list in the AJAXUploader LayoutTemplate that has 1,2,3 . . for values, and is set to autopostback and OnSelectedIndexChanged="ddlNumFiles_SelectedIndexChanged"
The problem is, this event doesn't get fired when the ddl is in the AJAXUploader control. The postback happens, but the associated event is "skipped". When I move the drop down list outside of the AJAXUploader, the event fires fine.
How to fix

3. When fuFiles.Rows is set greater then 1 (say to 3 for instance) the spacing is too great between each row. I am using the LayoutTemplate as you will see below and have not found a way of decreasing the spacing.

Thank you!!!

Code: HTML/ASPX
<eo:Dialog runat="server" id="dlgFileEditor"
	CloseButtonUrl="/masterpages/theme_orange/Close_Simple.png"
	IsModal="true" AllowResize="True"
	ControlSkinID="None" Width="500px"  
	ShadowColor="LightGray"   ShadowDepth="3"
	ResizeImageUrl="00020014" HeaderHtml="File Editor"
	BackShadeColor="gray" BackShadeOpacity="50"	>
	<HeaderStyleActive CssText="Color:#fff; font-weight:bold; padding-right: 4px; padding-left: 4px; background:url('/masterpages/Theme_Orange/TitleBar.png') repeat-x left top;"></HeaderStyleActive>
	<ContentStyleActive CssClass="ControlBackground"></ContentStyleActive>
	<ContentTemplate>
		<eo:AJAXUploader runat="server" ID="fuFiles" AutoPostBack="true" OnFileUploaded="FileUploaded" TempFileLocation="d:\CMS_Upload_Files_Temp">
		<LayoutTemplate>
		<div class="ControlBar">
			<div class="ControlBarLeft">
				Files to Upload 
				<asp:DropDownList ID="ddlNumFiles" runat="server" CssClass="TitleBarControls" AutoPostBack="true" OnSelectedIndexChanged="ddlNumFiles_SelectedIndexChanged" >
					<asp:ListItem Value="1" />
					<asp:ListItem Value="2" />
					<asp:ListItem Value="3" />
					<asp:ListItem Value="4" />
					<asp:ListItem Value="5" />
					<asp:ListItem Value="6" />
					<asp:ListItem Value="7" />
					<asp:ListItem Value="8" />
					<asp:ListItem Value="9" />
					<asp:ListItem Value="10" />
					<asp:ListItem Value="11" />
					<asp:ListItem Value="12" />
					<asp:ListItem Value="13" />
					<asp:ListItem Value="14" />
					<asp:ListItem Value="15" />
				</asp:DropDownList>
			</div>
			<div class="ControlBarRight">
				<asp:LinkButton id="UploadButton" runat="server" Text="span>" CssClass="button"></asp:LinkButton>
			</div>
		</div>
		<asp:Table ID="tblFileEditor" BorderStyle="none" CellSpacing="0" CssClass="TableDetailsView" runat="server" EnableTheming="false">
		<asp:TableRow>
			<asp:TableHeaderCell>
				<asp:Image ID="imgFileImage" runat="server" />
				<asp:Textbox ID="tbxFileID" runat="server" Visible="false" />
				File
			</asp:TableHeaderCell>
			<asp:TableCell>
				<asp:PlaceHolder id="InputPlaceHolder" runat="server" />
				<eo:ProgressBar id="ProgressBar" runat="server" ControlSkinID="None" Height="18px"  BorderColor="black" BorderStyle="Solid" BorderWidth="1px" BackColor="#f4c3a3" IndicatorColor="#ec7e3b" />
				<asp:PlaceHolder id="ProgressTextPlaceHolder" runat="server" />
				<asp:PlaceHolder id="PostedFilesPlaceHolder" runat="server" />
				
			</asp:TableCell>
		</asp:TableRow>
		<asp:TableRow>
			<asp:TableHeaderCell>
				Group
			</asp:TableHeaderCell>
			<asp:TableCell>
				<asp:DropDownList ID="ddlFileEditorGroup" OnDataBound="ddlFileEditorGroup_OnDataBound" runat="server" DataSourceID="dsFileEditorGroups" DataTextField="GroupName" DataValueField="GroupID" AppendDataBoundItems="true" >
					<asp:ListItem Text="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --None--" Value="" Selected="true" />
				</asp:DropDownList>
				<asp:SqlDataSource ID="dsFileEditorGroups" runat="server" ConnectionString="<%$ ConnectionStrings:Conn_CMS_View %>" SelectCommand="SELECT * FROM [Groups] WHERE ([SiteID] = @SiteID) ORDER BY [GroupName]">
					<SelectParameters>
						<asp:SessionParameter Name="SiteID" SessionField="Site" Type="Int32" />
					</SelectParameters>
				</asp:SqlDataSource>
			</asp:TableCell>
		</asp:TableRow>
		<asp:TableRow>
			<asp:TableHeaderCell>
				Title
			</asp:TableHeaderCell>
			<asp:TableCell>
				<asp:TextBox ID="tbxFileTitle" runat="server" Width="98%" />
			</asp:TableCell>
		</asp:TableRow>
		 . . . Code Deleted
		</asp:Table>
	</LayoutTemplate>
</eo:AJAXUploader>
</ContentTemplate>
</eo:Dialog>


Code: C#
protected void ddlNumFiles_SelectedIndexChanged(object sender, EventArgs e)
	{
		DropDownList ddlNumFiles = (DropDownList)dlgFileEditor.ContentContainer.FindControl("ddlNumFiles");
		AJAXUploader fuFiles = (AJAXUploader)dlgFileEditor.ContentContainer.FindControl("fuFiles");
		fuFiles.Rows = Convert.ToInt32(ddlNumFiles.SelectedValue);
	}
	protected void FileUploaded(object sender, EventArgs e)
	{
		//Get all the posted files
		AJAXUploader fuFiles = (AJAXUploader)dlgFileEditor.ContentContainer.FindControl("fuFiles");
		AJAXPostedFile[] files = fuFiles.PostedFiles;
		foreach (AJAXPostedFile file in files)
		{
			FileStream fs1 = new FileStream(file.TempFileName, FileMode.Open);

			byte[] imageBytes = new byte[fs1.Length];
			fs1.Read(imageBytes, 0, imageBytes.Length);
			fs1.Close();
			fs1.Dispose();
			string strExtension = GetExtension(file.ClientFileName.ToString().Trim());

			TextBox tbxFileTitle = (TextBox)fuFiles.FindControl("tbxFileTitle");
			. . . some code deleted
			//Get proper File Title
			string strFileTitle = "";
			if (tbxFileTitle.Text.ToString().Trim() == "")
				strFileTitle = file.ClientFileName.ToString();
			else
				strFileTitle = tbxFileTitle.Text.ToString().Trim();
			. . . save code deleted
		files = null;
		fuFiles.ClearPostedFiles();
		fuFiles.Dispose();
	}


David L. Sargent
Developer
Washington State University
eo_support
Posted: Tuesday, September 18, 2007 7:56:36 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,089
Hi Sarge,

#1 and #2 are related and it seems to be a bug. What happens is the uploader does not initialize LayoutTemplate until render --- so all the child controls does not exist until then, which caused both problems. We will get this fixed as soon as possible.

As for #3, the mininum gap between two rows is the gap between two textbox. IE seems to always place a gap between two texbox (vertical gap) regardless style settings. This gap seems to be 2 pixels. Other browsers, noticeably FireFox, does not seem to place any gaps. If it appears bigger than that, try temporarily comment out your .css file and see if it helps. Internally we use a TABLE to holds the multiple rows. So if you have a CSS rule that affects all TDs, they will be affected as well.

We will update the forum when #1 and #2 are fixed.

Thanks
eo_support
Posted: Friday, September 21, 2007 6:40:48 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,089
Hi Sarge,

We've posted a new build that address #1 and #2. Please see your private messages for download location.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.