Help or suggestion to build a list of values control
Hi all, Ill do my best to explain as best I can.
I'm trying to build a list of values from which a user can select either individual list items or multiple. (See attachments)
The control currently consists of a drop down list and an hyperlink. If the user is to select an individual item then it is simply a matter of binding the values to the drop down list and the hyperlink is disabled and not visible. However if the user may select multiple items you cannot do it with the conventional drop down list, it will be a list box. In this case the hyperlink is enabled and visible, when clicked on opens up a new window via javascript, the window opened is determined by the height and width set in the control tag. Usually only 350 x 250.
This window has two forms, the first has a text box and beside it a submit/search button, which I want to display if the control tag in the other window has the attribute Search set to true. Upon a user clicking the search button it fills the list box, which is in the second form, with values that match the criteria. The second form also has a submit button. The user will select these items as necessary and click the submit button this will send the select items back to the drop down list in the parent window and close the popup window.
The reason I'm doing it this way is to save space, as I will be having this control multiple times on the same page. I just need to find a way of getting the control attributes/properties to the popup without a huge ugly querystring, surely there has got to be a cleaner way to do this. Following is some of the code. I have also placed a couple of screen shots on my website http://geocities.com/illcomms/ these were done when I was using ASP and now wanting something similar in .Net.
Listing.ascx (The control itself)
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="Listing.ascx.cs" Inherits="Projects.Listing" %>
<aspropDownList ID="ddlMainListing" style="width:200px;" Runat="Server"/>
<asp:image id="imgShowList" style="vertical-align:middle;" Runat="server" ImageUrl="../images/dropDownUp.jpg" AlternateText="Select"/>
Listing.ascx.cs (The controls code behind)
namespace Projects
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public class Listing : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.DropDownList ddlMainListing;
protected System.Web.UI.WebControls.Image imgShowList;
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public bool _MultipleSelection;
public bool _MultipleLine;
public bool _Search;
public int _WindowSizeHeight;
public int _WindowSizeWidth;
public string _WindowTitle;
public bool MultipleSelection
{
get { return _MultipleSelection; }
set { _MultipleSelection = value; }
}
public bool MultipleLine
{
get { return _MultipleLine; }
set { _MultipleLine = value; }
}
public bool Search
{
get { return _Search; }
set { _Search = value; }
}
public int WindowSizeHeight
{
get { return _WindowSizeHeight; }
set { _WindowSizeHeight = value; }
}
public int WindowSizeWidth
{
get { return _WindowSizeWidth; }
set { _WindowSizeWidth = value; }
}
public string WindowTitle
{
get { return _WindowTitle; }
set { _WindowTitle = value; }
}
imgShowList.Attributes.Add("onclick", scriptStr);
}
else
{
//This is where if single selection is done, where binding of data is done straight to the drop down list.
}
}
}
}
Menu.aspx.cs (code behind)
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Page_Load(object sender, System.EventArgs e)
{
// This is where I need to find out if Search is enabled
// on the control.
// one other thing that I will add later is the stored procedure which it is to call
if (Search == true)
{
//These are disabled by default
txtSearch.Visible = true;
txtSearch.Enabled = true;
btnSearch.Visible = true;
btnSearch.Enabled = true;
}
}
}
}
Bookmarks