.net calendar - making the whole cell perform postback (clickable)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 10:02:35

问题


I've got a .net calendar up and running and bringing information from a database. By default the day number has a post back action applied to it.

What I'm trying to do is have that action apply to the whole cell so the user doesn't need to click on just the text link.

I'm the dayRenderer action i have the following line to try and replicate the action but the second argument I'm not sure how to set it.

It appears to give it an id e.g. 3315 but I'm not sure how to get the required id manually for this code below. I hope this makes sense! I'm new to .NET so not very savvy with my terminology!

e.Cell.Attributes.Add("OnClick", 
    string.Format("javascript:__doPostBack('{0}','{1}')", 
    Calendar1.ClientID, ***ID_NEEDED_HERE***));

回答1:


The parameter is the number of days since Jan 1 2000 for the first day of your calendar, preceded by a 'V'.

So an ID of 'V0' means Jan 1 2000, an ID of 'V5' means Jan 6 2000, an ID of 'V-5' means Dec 27, 1999.

Cheers,

Ruben




回答2:


putting

e.Cell.Attributes.Add("OnClick",e.SelectUrl);

in your dayRenderer will simulate the number click.




回答3:


This my answer after I tried to figure it out this for about a day. In DayRender Event you have to paste this code or create a Sub() and call it from there

Private AdditionaleText Sub(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs)

dim text as string = "MyText"

e.Cell.Text = "< ref= " & e.SelectUrl & "" style=""color:#663399 font-size: X-small"">""

'Here you also can customize the style of the Text

e.Cell.Text += text & "
" & e.Day.DayNumberText e.Cell.Attributes.Add("OnClick",e.SelectUrl);

End Sub

You could use only the last sentence but is not going to show you the text as a Clickable on, but it works The hole code it looks much better the e.SelectUrl give you the same ref you could retrieve invoking

"javascript:__doPostBack('ctl00$ctl00$MainContent$ContentPlaceHolder1$CalendarSailingDay$Calendar','" & ID & " style=""color:#663399"" >

....that is acctually very confusing. GOOD LUCK!!!



来源:https://stackoverflow.com/questions/619277/net-calendar-making-the-whole-cell-perform-postback-clickable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!