ラベル build の投稿を表示しています。 すべての投稿を表示
ラベル build の投稿を表示しています。 すべての投稿を表示

2012年3月26日月曜日

Restricting Dates in an AJAX Calendar

I need to build some logic into my ajax calendar control to prevent the user from entering a date that is less than today's date. I have two text boxes with one called SDate and another called FDate. Each of these text boxes have AJAX calendar extenders attached. So i am trying to figure out when the user clicks the text box, they can only select a date from the AJAX calendar that occurs from today's date onwards. The previous dates should be unselectable.

I thought the follwing code would work, but it seems it does not, as the AJAX calendar control doesn't seem to have the DayRender feature of the full .NET calendar.

ProtectedSub CEStartDate_DayRender(ByVal senderAsObject,ByVal eAs DayRenderEventArgs)

If e.Day.[Date] < Today()Then

e.Day.IsSelectable =False

Else

e.Day.IsSelectable =True

EndIf

EndSub

Any thoughts??

Hi Lochview,

Yes , we can keep the select date in within boundies when we use Calendar but not CalendarExtender(Ajax control). Based on the research of its source code, we can find that CalendarExtender generated all on the client using Javascript and we can control less on the server side. So unfortunately, we cannot achieve what you want by using any direct properties or functions unless we modify its source code. Below is the code snippet which is used to generate its days.

_buildDays : function() {
/// <summary>
/// Builds a "days of the month" view for the calendar
/// </summary>

var dtf = Sys.CultureInfo.CurrentCulture.dateTimeFormat;

this._days = $common.createElementFromTemplate({
nodeName : "div",
cssClasses : [ "ajax__calendar_days" ]
}, this._body);
this._modes["days"] = this._days;

this._daysTable = $common.createElementFromTemplate({
nodeName : "table",
properties : {
cellPadding : 0,
cellSpacing : 0,
border : 0,
style : { margin : "auto" }
}
}, this._days);

this._daysTableHeader = $common.createElementFromTemplate({ nodeName : "thead" }, this._daysTable);
this._daysTableHeaderRow = $common.createElementFromTemplate({ nodeName : "tr" }, this._daysTableHeader);
this._daysBody = $common.createElementFromTemplate({ nodeName: "tbody" }, this._daysTable);

for (var i = 0; i < 7; i++) {
var dayCell = $common.createElementFromTemplate({ nodeName : "td" }, this._daysTableHeaderRow);
var dayDiv = $common.createElementFromTemplate({
nodeName : "div",
cssClasses : [ "ajax__calendar_dayname" ]
}, dayCell);
}

for (var i = 0; i < 6; i++) {
var daysRow = $common.createElementFromTemplate({ nodeName : "tr" }, this._daysBody);
for(var j = 0; j < 7; j++) {
var dayCell = $common.createElementFromTemplate({ nodeName : "td" }, daysRow);
var dayDiv = $common.createElementFromTemplate({
nodeName : "div",
properties : {
mode : "day",
innerHTML : " "
},
events : this._cell$delegates,
cssClasses : [ "ajax__calendar_day" ]
}, dayCell);
}
}
}

I hope this help.

Best regards,

Jonathan.

2012年3月24日土曜日

Returning a dataset

I am using the Atlas bits that run on the RC build. I thought that there was the capability to return a dataset. Is that working at this point? I am getting a strange error where the local WebDev.WebServer.exe is generating an error and then exiting when I attempt to call a webservice that returns a dataset. The code is pretty simple, so I have included it here just incase I am doing something stupid. I am able to step thru my code, I exit from the method, and then bang I get the error on the terminal. Thoughts? Do I need to change what I am doing? Did I just make up the thought that Datasets were working at this point?
Wally

[WebMethod]

public System.Data.DataSet ReturnDataSet()

{

DataSet ds =newDataSet();

DataTable dt =newDataTable();

DataRow dr;

dt.Columns.Add(newDataColumn("tblStateId", System.Type.GetType("System.Int32")));

dt.Columns.Add(newDataColumn("State", System.Type.GetType("System.String")));

dr = dt.NewRow();

dr["tblStateId"] = 1;

dr["State"] ="Tennessee";

dt.Rows.Add(dr);

dr = dt.NewRow();

dr["tblStateId"] = 2;

dr["State"] ="Alabama";

dt.Rows.Add(dr);

ds.Tables.Add(dt);

return (ds);

}

Interesting. This looks like a bug in Atlas. When I try your code, I get a StackOverflow exception in the serialization process.

Yes, the StackOverflow Exception is what I got also. Sorry fornot being descriptive enough last night. I was a little tired andI am getting the flu. Sad [:(]

I suspect a bug in the DataSetConverter, which is probably caused by circular references between the DataSet and its DataTables.
What you could do for now is to return a DataTable instead (and not use a DataSet at all).

publicoverridestring Serialize(object o)
{
if (!(ois DataSet))
{
thrownew ArgumentException();
}
DataSet set1= (DataSet) o;
StringBuilder builder1=new StringBuilder();
builder1.Append('[');
bool flag1=true;
IEnumerator enumerator1= set1.Tables.GetEnumerator();
try
{
while (enumerator1.MoveNext())
{
DataTable table1= (DataTable) enumerator1.Current;
if (!flag1)
{
builder1.Append(',');
}
builder1.Append(JavaScriptObjectSerializer.Serialize(set1));
flag1=false;
}
}
finally
{
IDisposable disposable1= enumerator1as IDisposable;
if (disposable1 !=null)
{
disposable1.Dispose();
}
}
builder1.Append(']');
return builder1.ToString();
}


Variable table1 wasn't used.
Serialize(set1) rises Stack Overflow exception