We are attempting to add a WebScheduleInfo control to our pages and are running into some problems with Content pages. We can successfully add all the required controls and access the SqlServer database from standalone aspx pages. But any attempts to add those exact same controls to a Master page results in a timed out connection to the database. Below are two example aspx pages.
testNoMaster.aspx. This sample works correctly, connects to the database and dispalys appointments for the current month.
<%@ Register Assembly="Infragistics35.WebUI.WebSchedule.v8.1, Version=8.1.20081.2033, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
<%@ Register Assembly="Infragistics35.WebUI.WebScheduleDataProvider.v8.1, Version=8.1.20081.2033, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
Namespace="Infragistics.WebUI.Data" TagPrefix="ig_scheduledata" %>
<head runat="server">
<body>
<form id="form1" runat="server">
<div>
SelectCommand=";"></asp:SqlDataSource>
<ig_scheduledata:WebScheduleSqlClientProvider ID="WebScheduleSqlClientProvider1"
WebScheduleInfoID="WebScheduleInfo1">
</ig_scheduledata:WebScheduleSqlClientProvider>
<igsch:WebScheduleInfo ID="WebScheduleInfo1" runat="server">
</igsch:WebScheduleInfo>
</igsch:WebMonthView>
</div>
</html>
This page times out when attempting to connect to the database. The controls in the content pane are a direct copy from the page above that works correctly.
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
Can anyone point me to a solution to this problem. If we can not find one we will most likely be finding some other controls to purchase instead.
Andrew Taft
Hi Andrew,
I believe the problem has to do with how you're setting the WebScheduleInfoId properties on the DataProvider. My guess is that it's not resolving the control correctly, b/c it's in a naming container.
Instead, you should use the CodeBehind to set the WebScheduleInfo property, on all controls, inclucing the View controls
Hope this helps,
-SteveZ
I tried this solution and it did not work. Mine gives me a login failed for sa but our connection string is using integrated security and it works fine if i take it out of a master page. Suggestions?
Since the controls are in a master page, all controls are "munged" by their naming container so SqlDataSource1 becomes MasterPageName$SqlDataSource1, etc. Consequently, the recommendation is that all controls being wired-up by their IDs (because their IDs are going to change on a master page or user control) should be assigned through code-behind.
So instead of using DataSourceID, you want to assign,
WebScheduleSqlClientProvider1.DataSource = SqlDataSource1
This one in particular is probably what's causing your particular message, because it sounds like the data provider is trying to create its own default DB connection instead of using the one you have set-up with integrated security in the data source control, and it would only do this if it couldn't find the data source control. Nonetheless, it's important to do this for connecting anything that had been connected via ID when using master pages.
So you have this code, and it works when it is not in a master page, but as soon as it is in a master page it stops working?
When you did what you describe in your first block of code,
WebScheduleOleDbProvider1.WebScheduleInfo = WebScheduleInfo1;WebScheduleOleDbProvider1.Connect(AccessDataSource1.ConnectionString);
can you elaborate on what happened when it didn't work? For example, did you get an error message? did it throw an exception? did both lines execute without any error? is the AccessDataSource1 ConnectionString property empty? is it referring to a WebSchedule#.mdb file in your Web application's App_Data sub-folder? are the other WebSchedule views on the master page also using this same instance of WebScheduleInfo1?
I tried all of these for the AccessDataSource and none of them work.
protected
void Page_Load(object sender, EventArgs e)
{
//Doesn't work
//WebScheduleOleDbProvider1.WebScheduleInfo = WebScheduleInfo1;
//WebScheduleOleDbProvider1.Connect(AccessDataSource1.ConnectionString);
//WebScheduleOleDbProvider1.WebScheduleInfo = this.WebScheduleInfo1;
//WebScheduleOleDbProvider1.DataSourceID = AccessDataSource1;
//Doesn't work - cannot be modified at run-time
//this.WebScheduleOleDbProvider1.DataSourceID = this.AccessDataSource1.ID;
//this.WebScheduleOleDbProvider1.DataSourceID = "ctl00$ContentPlaceHolder1$AccessDataSource1";
}
Thanks. That worked for me.
In code behind I have:
WebScheduleSqlClientProvider1.WebScheduleInfo = WebScheduleInfo1; WebScheduleSqlClientProvider1.Connect(SqlDataSource1.ConnectionString);
levon said:So you cannot do WebScheduleSqlClientProvider1.DataSource = SqlDataSource1 because there is no DataSource property for WebScheduleSqlClientProvider.
My mistake, there is no DataSource property. In that case, what you can do is call the Connect method when initializing,
WebScheduleSqlClientProvider1.Connect( SqlDataSource1.ConnectionString);
So you cannot do WebScheduleSqlClientProvider1.DataSource = SqlDataSource1 because there is no DataSource property for WebScheduleSqlClientProvider. When I try to assign DataSourceID:
WebScheduleSqlClientProvider1.DataSourceID = SqlDataSource2.ID;
I get "The DataSourceID cannot be modified at run-time. Change the Connection reference directly to assign another Connection object to the data provider" I don't want to hardcode HTML connection strings in code behind either. So how do we assign the ID's in code behind?