我想在每次点击按钮时弹出一条消息。 此弹出窗口显示一些信息,并根据我的代码后置值更新其标签。
我尝试了不同的事情,例如声明变量 protected 或 public :
Protected test As string = "test"
'(...)
test = "another string"
在.aspx文件中:
<%=test%>
但后来我注意到我在服务器端控件(例如<%=%>
)的属性中不能有<asp:Label>
块。
我试图在代码隐藏本身中设置.Text
属性,它适用于页面加载,但我想动态地在另一个函数中设置.Text
值。
Protected Sub Page_Load(object sender, EventArgs e)
If Not Page.IsPostBack Then
pagenumberLabel.Text = GetPagingCaptionString()
End If
End Sub
我还尝试创建隐藏按钮并通过javascript执行点击,但未传递值。
[ASPx.VB]
Protected fileName As string = ""
Protected Sub UpdatePopup(ByVal fileName As String)
'fileName = "write my file name"
ASPxLabelName.Text = fileName
' this doens't work (filename="")
End Sub
' OR
Protected Sub UpdateButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles UpdateButton.Click
fileName = "write my file name"
ASPxLabelName.Text = fileName
' This works but it is not dynamic as wanted
End Sub
[ASPX]
<dx:ASPxPopupControl ID="ASPxPopupControl1" runat="server" ClientInstanceName="ShowMessageInfo"
CloseAction="CloseButton" CloseOnEscape="True" EnableViewState="False"
PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter"
HeaderText="HEADER" AllowDragging="True" Modal="True"
PopupAnimationType="Fade" PopupAction="None" Width="400px">
<ContentCollection>
<dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
<dx:ASPxPanel ID="Panel1" runat="server">
<PanelCollection>
<dx:PanelContent ID="PanelContent1" runat="server">
<table cellspacing="0" cellpadding="5" width="100%">
<tr>
<td>Name:</td>
<td><dx:ASPxLabel ID="ASPxLabelName" runat="server" Text="">
</dx:ASPxLabel></td>
</tr>
</table>
<dx:ASPxButton ID="UpdateButton" runat="server" Text="Update Content"
style="display:none" AutoPostBack="False">
<ClientSideEvents Click="function(s, e) { ShowMessageInfo.PerformCallback(); }" />
</dx:ASPxButton>
</dx:PanelContent>
</PanelCollection>
</dx:ASPxPanel>
</dx:PopupControlContentControl>
</ContentCollection>
</dx:ASPxPopupControl>