3
Answers

Dynamically adding Textbox w/MaskedEditExtender into a calendar cell. How? Ill pay you for answer.

Justin N

Justin N

13y
5.6k
1
I have included the source code.  This fails everytime.  This problem shouldn't be as hard as it is, but if someone could give me a good solution I would be greatly happy.

PS The code needs to be ran in a project because simply looking at the code doesnt describe the problem.  The error that I get says that the "Page cannot be null".  I need a pros help!  And yes! If someone gets me an answer that works ill send you a check for 50 American Dollars. Scouts honor.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;

namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
int i = 1;
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
TextBox t = new TextBox();
t.ID = "t" + i;
e.Cell.Controls.Add(t);

MaskedEditExtender mee1 = new MaskedEditExtender();
mee1.AcceptAMPM = true;
mee1.Mask = "99:99";
mee1.MaskType = MaskedEditType.Time;
mee1.TargetControlID = t.ID;
mee1.ClearMaskOnLostFocus = false;
mee1.ClientIDMode = System.Web.UI.ClientIDMode.Static;
mee1.ID = "MaskedEditExtender" + i++;
e.Cell.Controls.Add(mee1);
}
}
}

Answers (3)