Yep it's a standard web part as far as i'm concerned but i'm still new to Kentico so the aspx is
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="RedirectorDropdown.ascx.cs"
Inherits="CMSWebParts_PullDigital_RedirectorDropdown" %>
<asp:DropDownList ID="ddlRedirector" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlRedirector_SelectedIndexChanged">
</asp:DropDownList>
and the code behind in total is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.GlobalHelper;
using CMS.PortalControls;
public partial class CMSWebParts_PullDigital_RedirectorDropdown : CMSAbstractWebPart
{
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!Page.IsPostBack)
{
EnsureItems();
}
}
public string TextValues
{
get
{
return ValidationHelper.GetString(GetValue("TextValues"), "");
}
set
{
SetValue("TextValues", value);
}
}
public string DataValues
{
get
{
return ValidationHelper.GetString(GetValue("DataValues"), "");
}
set
{
SetValue("DataValues", value);
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
private void EnsureItems()
{
if (ddlRedirector.Items.Count == 0)
{
string[] textValues = TextValues.Split(';');
string[] dataValues = DataValues.Split(';');
if (textValues.Length > 0 && textValues.Length == dataValues.Length)
{
ddlRedirector.Items.Add(new ListItem("", ""));
for (int i = 0; i < textValues.Length; i++)
{
ddlRedirector.Items.Add(new ListItem(textValues, dataValues));
}
}
}
}
protected void ddlRedirector_SelectedIndexChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(ddlRedirector.SelectedValue))
{
Response.Redirect(ddlRedirector.SelectedValue);
}
}
}
The redirector method is never firing and the control is not repopulated on postback from viewstate but this won't be a problem as the control is redirecting the user to a new page.