Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
lblDates.Text = "You selected" & Calendar1.SelectedDate.ToLongDateString()
End Sub
Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs) Handles Calendar1.DayRender
If e.Day.IsWeekend Then
e.Cell.BackColor = System.Drawing.Color.Green
e.Cell.ForeColor = System.Drawing.Color.Yellow
e.Day.IsSelectable = False
End If
End Sub
Partial Class ViewStateTest
Inherits System.Web.UI.Page
Protected Sub cmdSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSave.Click
'save the current text
SaveAllText(Page.Controls, True)
End Sub
Private Sub SaveAllText(ByVal controls As ControlCollection, ByVal saveNested As Boolean)
For Each Control As Control In controls
If TypeOf Control Is TextBox Then
'store the text using the unique control id
ViewState(Control.ID) = (CType(Control, TextBox)).Text
End If
If (Control.Controls IsNot Nothing) AndAlso saveNested Then
SaveAllText(Control.Controls, True)
End If
Next
End Sub
Protected Sub cmdRestore_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdRestore.Click
RestoreAllText(Table1.Controls, True)
End Sub
Private Sub RestoreAllText(ByVal controls As ControlCollection, ByVal saveNested As Boolean)
For Each Control As Control In controls
If TypeOf Control Is TextBox Then
If ViewState(Control.ID) IsNot Nothing Then
CType(Control, TextBox).Text = CStr(ViewState(Control.ID))
End If
End If
If (Control.Controls IsNot Nothing) AndAlso saveNested Then
RestoreAllText(Control.Controls, True)
End If
Next
End Sub
End Class
public partial class DetailsView : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
StringBuilder info = new StringBuilder();
info.AppendFormat("You are viewing record {0} of {1}
",
CustomerDetails.DataItemIndex.ToString(),
CustomerDetails.DataItemCount.ToString());
for (int i = 0; i < CustomerDetails.DataKeyNames.Length; i++)
{
info.AppendFormat("{0} : {1}
", CustomerDetails.DataKeyNames[i], CustomerDetails.DataKey.Values[i]);
}
info.AppendFormat("Selected Value: {0}", CustomerDetails.SelectedValue.ToString());
lblInfo.Text = info.ToString();
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment