HyperLink href = (HyperLink)row.Cells[0].Controls[0];
string text = href.Text;
怎样在UpdatePanel里使用FileUpload控件
HTML:
<div>
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</atlas:ScriptManager>
<atlas:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" /><asp:Button ID="cmdButton1" runat="server"
Text="Upload" /><asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</ContentTemplate>
</atlas:UpdatePanel>
<asp:Button ID="cmdButton2" OnClick="cmdButton2_click" runat="server" Text="Full post back" />
</div>
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</atlas:ScriptManager>
<atlas:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" /><asp:Button ID="cmdButton1" runat="server"
Text="Upload" /><asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</ContentTemplate>
</atlas:UpdatePanel>
<asp:Button ID="cmdButton2" OnClick="cmdButton2_click" runat="server" Text="Full post back" />
</div>
CODE BEHIND:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.cmdButton1.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(Me.cmdButton2, ""))
End Sub
Protected Sub cmdButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Me.FileUpload1.HasFile Then
System.Threading.Thread.Sleep(1000)
Me.Label1.Text = Me.FileUpload1.FileName
End If
End Sub
Me.cmdButton1.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(Me.cmdButton2, ""))
End Sub
Protected Sub cmdButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Me.FileUpload1.HasFile Then
System.Threading.Thread.Sleep(1000)
Me.Label1.Text = Me.FileUpload1.FileName
End If
End Sub