Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sure is possible I wrote up articles about imagebuttons and linkbuttons, follow the same form here: <a href="http://weblogs.sqlteam.com/jhermiz/archive/2007/12/10/Cool-Tricks-With-The-ASP.net-Calendar.aspx" rel="nofollow">http://weblogs.sqlteam.com/jhermiz/archive/2007/12/10/Cool-Tricks-With-The-ASP.net-Calendar.aspx</a></p> <p>When you write your event you just need to specify the <code>Handle</code> of that event.</p> <h2>Edit</h2> <p>After thinking about this some more this may in fact not be possible due to the way the asp.net lifecycle functions and how it handles the <code>DayRender</code> event.</p> <p>Even if you do something to this effect:</p> <pre><code>protected void Calendar1_Render(object sender, DayRenderEventArgs e) { if (e.Day.IsWeekend) { DropDownList d = new DropDownList(); d.ID = "bah" + e.Day.Date.ToShortDateString(); d.AutoPostBack = true; d.SelectedIndexChanged += new EventHandler(DropDownList1_SelectedIndexChanged); d.Items.Add("A"); d.Items.Add("B"); d.Items.Add("C"); e.Cell.Controls.Add(d); } } </code></pre> <p>This won't work since the page load event has already fired by the time each day is rendered, so even setting <code>Autopostback=true</code> wont work. </p> <p>In addition even if you assign a new <code>EventHandler</code> to the dynamic control it wont work as in this case:</p> <p><code>d.SelectedIndexChanged += new EventHandler(yourMethod);</code></p> <p>The only thing I can come up with that might work is something to this effect:</p> <pre><code> protected void Calendar1_Render(object sender, DayRenderEventArgs e) { if (e.Day.IsWeekend) { DropDownList d = new DropDownList(); d.ID = "bah" + e.Day.Date.ToShortDateString(); d.Items.Add("A"); d.Items.Add("B"); d.Items.Add("C"); d.Attributes.Add("onchange", "__doPostBack();"); e.Cell.Controls.Add(d); } } </code></pre> <p>The issue is this doesn't fire your server event it only fires a post back, but it gives you an idea that it could fire it via some attributes and client side scripting. Could you change your server method to be a client method? If so this would work, you'd replace <code>__doPostBack()</code> with the name of your client side method.</p> <p>Unfortunately I am not an ASP.net expert, I dab in too many other things, but this information is pretty solid when it comes to the Calendar control, I've used it a lot in the past and got to the point where I had to stop using it due to its limitations.</p> <p>Good luck.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload