Notification.OnResponseSubmitted 方法
引發 ResponseSubmitted 事件。
命名空間: Microsoft.WindowsCE.Forms
組件: Microsoft.WindowsCE.Forms (在 Microsoft.WindowsCE.Forms.dll 中)
語法
'宣告
Protected Overridable Sub OnResponseSubmitted ( _
e As ResponseSubmittedEventArgs _
)
'用途
Dim e As ResponseSubmittedEventArgs
Me.OnResponseSubmitted(e)
protected virtual void OnResponseSubmitted(
ResponseSubmittedEventArgs e
)
protected:
virtual void OnResponseSubmitted(
ResponseSubmittedEventArgs^ e
)
protected function OnResponseSubmitted(
e : ResponseSubmittedEventArgs
)
參數
備註
透過使用者輸入來關閉訊息提示,或超過了 InitialDuration 時間,都會發生 ResponseSubmitted 事件。Response 屬性包含字串,內含 HTML 表單的結果或使用者所按的按鈕或連結名稱。您可針對與應用程式相關的值來剖析此字串。
引發事件會透過委派 (Delegate) 叫用事件處理常式。如需詳細資訊,請參閱引發事件。
OnResponseSubmitted 方法也允許衍生類別處理事件,而不需附加委派。這是在衍生類別中處理事件的慣用技巧。
繼承者注意事項
在衍生類別中覆寫 OnResponseSubmitted 時,請務必呼叫基底類別的 OnResponseSubmitted 方法,讓註冊的委派可接收事件。
範例
下列程式碼範例將針對 HTML 表單中選取的值和訊息提示中的其他項目名稱,來剖析 Response 屬性。這個程式碼範例是 Notification 類別完整範例的一部分。
' When a ResponseSubmitted event occurs, this event handler
' parses the response to determine values in the HTML form.
Private Sub OnResponseSubmitted(obj As Object, _
resevent As ResponseSubmittedEventArgs) Handles Notification1.ResponseSubmitted
' Use a StringBuilder to create a log of the response.
Dim LogResponse As New StringBuilder()
' If the response contains the name specified for the action value
' of the HTML form, in this case "notify," get the value of the
' selected option from the SELECT list. An example of the
' response string would be notify?lstbx=0.
If resevent.Response.Substring(0, 6) = "notify" Then
Dim choice As Integer = Convert.ToInt32(resevent.Response.Substring(13, 1))
Select Case choice
Case 0
LogResponse.Equals("submit")
Case 1
LogResponse.Equals("opt 1")
Case 2
LogResponse.Equals("opt 2")
Case 3
LogResponse.Equals("opt 3")
Case 4
LogResponse.Equals("opt 4")
End Select
' If the checkbox in the form is checked, the response
' string could be as follows: notify?lstbx=0chkbx=on
' You can determine whether the check box is selected
' by checking whether the response ends with "on".
If resevent.Response.EndsWith("on") Then
LogResponse.Equals("checkbox")
End If
' If the user clicked the settings link,
' log the response. This example could display
' a dialog box by activating another form.
ElseIf resevent.Response = "settings" Then
' Display a settings dialog by activating
' a form named 'Settings':
' Settings.Activate
LogResponse.Equals("Postponed by clicking link")
' The user needs to respond to the notification
' after checking the settings, so set the
' InitialDuration and Visible properties so
' that the icon appears in the title bar.
Notification1.InitialDuration = 0
Notification1.Visible = True
End If
' Display the response on the status bar.
StatusBar1.Text = LogResponse.ToString() + " HTML: " + resevent.Response.ToString()
End Sub
// When a ResponseSubmitted event occurs, this event handler
// parses the response to determine values in the HTML form.
private void OnResponseSubmitted(object obj, ResponseSubmittedEventArgs resevent)
{
// Use a StringBuilder to create a log of the response.
StringBuilder LogResponse = new StringBuilder();
// If the response contains the name specified for the action value
// of the HTML form, in this case "notify," get the value of the
// selected option from the SELECT list. An example of the
// response string would be notify?lstbx=0.
if (resevent.Response.Substring(0, 6) == "notify")
{
int choice = Convert.ToInt32(resevent.Response.Substring(13, 1));
switch (choice)
{
case 0:
LogResponse.Equals("submit");
break;
case 1:
LogResponse.Equals("opt 1");
break;
case 2:
LogResponse.Equals("opt 2");
break;
case 3:
LogResponse.Equals("opt 3");
break;
case 4:
LogResponse.Equals("opt 4");
break;
}
// If the checkbox in the form is checked, the response
// string could be as follows: notify?lstbx=0chkbx=on
// You can determine whether the check box is selected
// by checking whether the response ends with "on".
if (resevent.Response.EndsWith("on"))
LogResponse.Equals("checkbox");
}
// If the user clicked the settings link,
// log the response. This example could display
// a dialog box by activating another form.
else if (resevent.Response == "settings")
{
// Display a settings dialog by activating
// a form named 'Settings':
// Settings.Activate
LogResponse.Equals("Postponed by clicking link");
// The user needs to respond to the notification
// after checking the settings, so set the
// InitialDuration and Visible properties so
// that the icon appears in the title bar.
notification1.InitialDuration = 0;
notification1.Visible = true;
}
// Display the response on the status bar.
statusBar1.Text = LogResponse.ToString() + " HTML: " + resevent.Response.ToString();
}
使用權限
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
平台
Windows Mobile for Pocket PC
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Compact Framework
支援版本:3.5、2.0