我对 mediaroom 的 TVButton 控件有疑问。mediaroom 演示框架附带了一些事件和操作。如何在我的代码中为 tvbutton 调用我自己的事件处理程序。onButtonClick="btnlogin_ButtonClick" 不起作用。如果我为 void btnlogin_ButtonClick(object sender,EventArgs e){ } 编写自定义代码
onButtonClick 没有触发!mediaroom的示例代码!
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SubmitAction_01_Designer.aspx.cs"
Inherits="TVPage_TVPage_Submit" %>
<%@ Register Assembly="TVControls" Namespace="Microsoft.TV.TVControls" TagPrefix="mrml" %>
<%@ Register Assembly="TVControls" Namespace="Microsoft.TV.TVControls.Actions" TagPrefix="mrml" %>
<form id="form1" runat="server">
<mrml:TVPage ID="TVPage1" runat="server" Style="position: absolute;">
<mrml:TVPanel ID="TVPanel2" runat="server" Background="image(file:/BG_Masthead.png)"
Style="z-index: 102; left: 0px; width: 632px; position: absolute; top: 0px; height: 99px">
<mrml:TVImage ID="TVImage2" runat="server" Style="left: 16px; width: 260px; position: absolute;
top: 23px; height: 80px" Url="file:///Brand_Service_Menu.png">
</mrml:TVImage>
<mrml:TVLabel ID="TVLabel3" runat="server" Background="@Transparent" Foreground="@TextHeader"
HorizontalAlign="right" VerticalAlign="bottom" Padding="rect(0,0,0,0)" Style="left: 265px;
width: 331px; position: absolute; top: 13px; height: 69px" Text="SubmitAction - Designer"
Wrap="false">
</mrml:TVLabel>
</mrml:TVPanel>
<mrml:TVText ID="TVText1" runat="server" Style="position: absolute; top: 137px; left: 347px;"
MaxChars="100">
</mrml:TVText>
<mrml:TVButton ID="TVButton1" runat="server" Style="position: absolute; top: 197px;
left: 352px;" OnClick="SubmitAction0" Text="Click To submit">
</mrml:TVButton>
<mrml:TVActions ID="TVActions1" runat="server" Actions-Capacity="4">
<mrml:SubmitAction Gadgets="TVText1" Method="Get" Name="SubmitAction0" Target=""
Url="SubmitAction_02_Designer.aspx" X="5" Y="5" />
</mrml:TVActions>
<mrml:TVLabel ID="TVLabel4" runat="server" Style="position: absolute; top: 137px;
left: 67px; height: 158px; width: 246px;" Text="Enter some text in TVText and click on TVButton to submit the TVpage. When the TVPage is submitted,
the control goes to the next page where you can see the text entered in the previous page.">
</mrml:TVLabel>
</mrml:TVPage>
</form>
所以这里我们只能给 OnClick="SubmitAction0"。上面的示例是源视图
示例背后的代码:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.TV.TVControls.Actions;
using Microsoft.TV.TVControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
/* <mrml:MoveAction Height="40" Left="270" Name="MoveAction0" Target="txtMove"
Top="138" Width="100" X="117" Y="117" />
<mrml:ShowAction Name="ShowAction0" Targets="lblShow" X="89" Y="89" />
<mrml:SetAction Name="SetAction0" PropertyName="value" PropertyValue="Set"
Target="txtSet" X="61" Y="61" />
<mrml:HideAction Name="HideAction0" Targets="lblHide" X="5" Y="5" />
<mrml:KeyAction Key="1" Name="KeyAction0" Target="txtKey" X="33" Y="33" />
<mrml:FocusAction Name="FocusAction0" Target="btnFocus" X="229" Y="100" />*/
MoveAction objMove = new MoveAction("MoveAction0", "txtMove", 270, 138, 100, 40);
TVActions1.Actions.Add(objMove);
ShowAction objShow = new ShowAction("ShowAction0", "lblShow");
TVActions1.Actions.Add(objShow);
SetAction objSet = new SetAction("SetAction0", "txtSet", "value", "Set");
TVActions1.Actions.Add(objSet);
HideAction objHide = new HideAction("HideAction0", "lblHide");
TVActions1.Actions.Add(objHide);
KeyAction objKey = new KeyAction("KeyAction0", "txtKey", "1");
TVActions1.Actions.Add(objKey);
FocusAction objFocus = new FocusAction("FocusAction0", "btnFocus");
TVActions1.Actions.Add(objFocus);
TVButton1.OnClick = new Microsoft.TV.TVControls.Events.ClickEvent("ShowAction0");
TVButton2.OnClick = new Microsoft.TV.TVControls.Events.ClickEvent("HideAction0");
TVButton3.OnClick = new Microsoft.TV.TVControls.Events.ClickEvent("SetAction0");
TVButton4.OnClick = new Microsoft.TV.TVControls.Events.ClickEvent("KeyAction0");
TVButton5.OnClick = new Microsoft.TV.TVControls.Events.ClickEvent("FocusAction0");
TVButton6.OnClick = new Microsoft.TV.TVControls.Events.ClickEvent("MoveAction0");
//Following lines are for displaying the file name
/*<mrml:TVLabel ID="lblFileName" runat="server"
style="position: absolute; top: 69px; left: 9px; width: 241px;" Text="TVLabel">
</mrml:TVLabel>*/
TVLabel lblFileName = new TVLabel();
lblFileName.ID = "lblFileName";
lblFileName.Left = 40;
lblFileName.Top = 70;
lblFileName.Width = 500;
lblFileName.Text = HttpContext.Current.Request.FilePath;
lblFileName.IsVisible = true;
TVPage1.Controls.Add(lblFileName);
}
}