Please help, i've been tearing my hair out for days on this one !!
I have the autocompleteextender inside a usercontrol as follows :
----------------------------------------------------------------------------------------------------------------------
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AutoControl.ascx.cs" Inherits="FormControls_AutoControl" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="DBauer.Web.UI.WebControls.DynamicControlsPlaceholder" Namespace="DBauer.Web.UI.WebControls" TagPrefix="DBWC" %>
<style type="text/css">
/* AutoComplete item */
.AutoComplete2_CompletionList
{
margin: 0px !important;
background-color: white;
color: black;
border: buttonshadow;
border-width: 1px;
border-style: solid;
cursor: 'default';
overflow: auto;
height: 200px;
text-align: left;
list-style-type: none;
padding-left: 1px;
}
/*AutoComplete flyout */
.AutoComplete2_CompletionListItem
{
background-color: white;
color: black;
padding: 1px;
cursor: hand;
}
/* AutoComplete highlighted item */
.AutoComplete2_HighlightedItem
{
background-color: #63B8FF;
color: black;
padding: 1px;
}
.AutoComplete2_img
{
background-image: url(~/images/autocomplete_leftcap.gif); background-position: right center; background-repeat: no-repeat;
}
</style>
<div id="divRenderEdit" runat="server" >
<asp:TextBox ID="txtValue" runat="server" Width="170px" CssClass="AutoComplete2_img"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AC1" runat="server" ServicePath="~/WebService.asmx" ServiceMethod="" UseContextKey="false"
CompletionListCssClass="AutoComplete2_CompletionList"
CompletionListItemCssClass="AutoComplete2_CompletionListItem"
CompletionListHighlightedItemCssClass="AutoComplete2_HighlightedItem"
MinimumPrefixLength="1" TargetControlID="txtValue" CompletionSetCount="20" CompletionInterval="1000"
OnClientItemSelected="AC1_itemSelected" onclientpopulating="ShowImage" onclientpopulated="HideImage">
</cc1:AutoCompleteExtender>
<asp:Label id="lblRequired" runat="server" Text="*" ForeColor="Red" Visible="False" Font-Bold="True" Font-Size="14pt"></asp:Label>
<asp:HiddenField ID="hdnID" runat="server" />
<asp:HiddenField ID="hdnAutoCompleteResultSet" runat="server" />
<asp:HiddenField ID="hdnIsRequired" value="N" runat="server" />
</div>
<div id="divRenderDisplay" runat="server" style="display:none;">
<asp:Label ID="lblValue" runat="server" Text=""></asp:Label>
</div>
<script type="text/javascript">
function AC1_itemSelected(sender, e)
{
var AC1Value = $get('<%= hdnID.ClientID %>');
AC1Value.value = e.get_value();
}
function ShowImage()
{
var auto_txt = $get('<%= txtValue.ClientID %>');
auto_txt.style.backgroundImage = 'url(~/images/autocomplete_spinner.gif)';
auto_txt.style.backgroundRepeat= 'no-repeat';
auto_txt.style.backgroundPosition = 'right';
}
function HideImage()
{
var auto_txt = $get('<%= txtValue.ClientID %>');
auto_txt.style.backgroundImage = 'url(~/images/autocomplete_leftcap.gif)';
}
</script>
-------------------------------------------------------------------------------------------------------------------
The ServiceMethod property is missing as it gets passed in dynamicaly via the property ACResultSet
on a page, just so I can have multiple instances of the control working with different entities, in this case companies and users.
I also have 2 web methods inside the web service as follows
----------------------------------------------------------------------------------------------------------------------
[WebMethod]
public string[] Company(string prefixText, int count)
{
List<string> titleArList = new List<string>();
string qry = "select companys.....;
SubSonic.QueryCommand qc= new SubSonic.QueryCommand(qry);
DataSet ds = SubSonic.DataService.GetDataSet(qc);
for (int i = 0; i < ds.Tables[0].Rows.Count;i++ )
{
DataRow row = ds.Tables[0].Rows[i];
titleArList.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(row["CompanyName"].ToString(), row["CompanyID"].ToString()));
}
return titleArList.ToArray();
}
[WebMethod]
public string[] Person(string prefixText, int count)
{
//return all records whose Title starts with the prefix input string
List<string> titleArList = new List<string>();
string qry = "select users.....;
SubSonic.QueryCommand qc= new SubSonic.QueryCommand(qry);
DataSet ds = SubSonic.DataService.GetDataSet(qc);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
DataRow row = ds.Tables[0].Rows[i];
str.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(row["UserFullName"].ToString(), row["UserID"].ToString()));
}
return titleArList.ToArray();
}
----------------------------------------------------------------------------------------------------------------------
and the 2 instance controls for customers and users are respectively inside their own (usercontrol) pages which make up, with others, one big page when displayed on screen, are as follows :
---------------------------------------------------------------------------------------------------------------------
<uc6:AutoControl ID="CompanyID" runat="server" DisplayName="Company" ValueWidth="250"
isRequired="false" DBField="CompanyID" ACResultSet="Company"/>
<uc6:AutoControl ID="UserID" runat="server" DisplayName="User" ValueWidth="200"
isRequired="true" DBField="UserID" ACResultSet="Person" >
--------------------------------------------------------------------------------------------------------------------
now to the knotty problem...........
Both controls work fine in terms of displaying the relevant data....but get this...I noticed a while ago something very strange...
Lets say for simplicity I have 3 companys, 1-Microsoft, 2-Apple, 3-IBM and 3 users 1-Bill Gates, 2-Steve Jobs, 3-Mr IBM (dont know anyone there) and I currently have selected 1-Microsoft and 1-Bill Gates (the two contols are mutually exclusive by the way, NOT linked in ANY logic)
When I change the user to 3-Mr IBM and SAVE the page, what actually happens is that the user control is ignored BUT the company has been saved as 3-IBM !!! (i.e the autocompleteextender has taken the correct ID 3 from the USER list and applied it to the COMPANY control instead !!! HOW BIZARRE, HOW CAN THIS POSSIBLY BE ???
Ive done a view source on the page to make sure the clientid property of the hidden ID which the autocompleteextender saves the selected items ID to, is in fact distinct (i.e relevant only to its instance, as created) AND IT IS. Also in case you are wondering whether ive blundered elsewhere and simply made a schoolboy error when saving, you'd be wrong, ive checked it...THOROUGHLY.
I'm toying with the idea of creating 2 web services and trying that, dont know why, i'm clutching at straws I guess, I just can't fathom this behaviour. I would be very grateful if anyone could give me a clue to the answer.
Thanks in advance
<
YAxis
AutoScale
=
"True"
IsZeroBased
=
"false"
>
Protected
Sub
RadChart1_PreRender(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
RadChart1.PreRender
Dim
TheMinValue
As
Double
Dim
TheMaxValue
As
Double
Dim
TheValue
As
Double
'Loop through each Y value in series 0 and get it's value. We need to get the
'Min and Max values for the entire chart.
'For seriescount As Integer = 0 To RadChart1.Series.Count - 1
For
itemcount
As
Integer
= 0
To
RadChart1.Series(0).Items.Count - 1
TheValue = RadChart1.Series(0).Item(itemcount).YValue
'assign default values in the 1st iteration of the loop
If
itemcount = 0
Then
TheMinValue = TheValue
TheMaxValue = TheValue
End
If
If
TheValue < TheMinValue
Then
TheMinValue = TheValue
If
TheValue > TheMaxValue
Then
TheMaxValue = TheValue
Next
If
TheMinValue = TheMaxValue
Then
'we have a problem because all Y values are equal. This is going to destroy the
'chart scaling along the left hand side.
'The below solution does not seem to work.
RadChart1.Series(0).PlotArea.YAxis.AutoScale =
False
RadChart1.Series(0).PlotArea.YAxis.MinValue = TheMinValue * 0.95
RadChart1.Series(0).PlotArea.YAxis.MaxValue = TheMaxValue * 1.05
RadChart1.Series(0).PlotArea.YAxis.
Step
= 5
Else
RadChart1.Series(0).PlotArea.YAxis.AutoScale =
True
End
If
End
Sub
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
telerik:RadRotator
ID
=
"AlertsRotator"
runat
=
"server"
RotatorType
=
"Buttons"
Height
=
"200px"
ItemHeight
=
"200px"
ScrollDirection
=
"Left"
Width
=
"500px"
ItemWidth
=
"500px"
>
<
ItemTemplate
>
<
div
style
=
"text-align: left"
>
<
table
width
=
"480px"
>
<
tr
>
<
td
align
=
"Center"
><
strong
><%# DataBinder.Eval(Container.DataItem," UserNotificationSubject") %></
strong
></
td
>
</
tr
>
<
tr
>
<
td
align
=
"left"
><%# DataBinder.Eval(Container.DataItem,"UserNotificationMessage") %></
td
>
</
tr
>
<
tr
>
<
td
>
<
input
type
=
"button"
value
=
"click me"
onclick
=
"alert('<%# DataBinder.Eval(Container.DataItem,"
UserNotificationSeqNum") %>')" /></
td
>
</
tr
>
</
table
>
</
div
>
</
ItemTemplate
>
</
telerik:RadRotator
>
Public
Partial
Class
Rotator
Inherits
System.Web.UI.Page
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
Dim
oData
As
New
DataTable
With
oData
.Columns.Add(
"UserNotificationSubject"
)
.Columns.Add(
"UserNotificationMessage"
)
.Columns.Add(
"UserNotificationSeqNum"
)
End
With
Dim
NewRow
As
DataRow = oData.NewRow
NewRow(
"UserNotificationSeqNum"
) =
"0"
NewRow(
"UserNotificationSubject"
) =
"Test User Notification Subject"
NewRow(
"UserNotificationMessage"
) =
"Test User Notifcation Message"
oData.Rows.Add(NewRow)
NewRow = oData.NewRow
NewRow(
"UserNotificationSeqNum"
) =
"1"
NewRow(
"UserNotificationSubject"
) =
"REMINDER"
NewRow(
"UserNotificationMessage"
) =
"Document T1 Reminder: I'm testing the reminders (To cancel this reminder use 20 on Document)"
oData.Rows.Add(NewRow)
NewRow = oData.NewRow
NewRow(
"UserNotificationSeqNum"
) =
"2"
NewRow(
"UserNotificationSubject"
) =
"REMINDER"
NewRow(
"UserNotificationMessage"
) =
"Document T1 Reminder: I'm testing the reminders adslfjkasd;lfja;ld jf;ladjf; lakjfd;askf jal;sdjf ;lasdjf;askjf;lka"
oData.Rows.Add(NewRow)
NewRow = oData.NewRow
NewRow(
"UserNotificationSeqNum"
) =
"3"
NewRow(
"UserNotificationSubject"
) =
"Web Entry Stuff"
NewRow(
"UserNotificationMessage"
) =
"The following document has been entered through the UI"
oData.Rows.Add(NewRow)
AlertsRotator.DataSource = oData
AlertsRotator.DataBind()
End
Sub
End
Class
Charts are bound to a class. 2 doubles and 1 date. The doubles are the y-axis series and the date is the x-axis
See the attached file for how it looks. LayoutMode is set to inside which moves the points but not the label.
Here is the code for the 1st chart:
<
div
class
=
"chartleft"
>
<
telerik:RadChart
ID
=
"RadChart1"
runat
=
"server"
DefaultType
=
"Line"
ChartTitle-TextBlock-Text
=
"Last 10 Updates"
Width
=
"525"
>
<
PlotArea
>
<
Appearance
Dimensions-Margins
=
"18%, 30%, 25%, 10%"
>
</
Appearance
>
<
EmptySeriesMessage
Visible
=
"True"
>
<
Appearance
Visible
=
"True"
>
</
Appearance
>
</
EmptySeriesMessage
>
<
YAxis
IsZeroBased
=
"false"
>
</
YAxis
>
<
XAxis
LayoutMode
=
"Inside"
AutoScale
=
"false"
LabelStep
=
"1"
DataLabelsColumn
=
"date"
>
<
Appearance
ValueFormat
=
"ShortDate"
MajorGridLines-Visible
=
"false"
>
<
LabelAppearance
RotationAngle
=
"45"
Position-AlignedPosition
=
"Top"
>
</
LabelAppearance
>
</
Appearance
>
</
XAxis
>
</
PlotArea
>
<
Series
>
<
telerik:ChartSeries
DataYColumn
=
"realvalues"
Name
=
"Real Values"
Type
=
"Line"
>
</
telerik:ChartSeries
>
<
telerik:ChartSeries
DataYColumn
=
"othervalues"
Name
=
"Trending Values"
Type
=
"Line"
>
</
telerik:ChartSeries
>
</
Series
>
</
telerik:RadChart
>
</
div
>
here is the class it is bound to:
public class chartdata
{
public double realvalues { get; set; }
public double othervalues { get; set; }
public double date { get; set; }
public chartdata(double r, double o, DateTime dt)
{
date = dt.ToOADate();
realvalues = r;
othervalues = o;
}
}