HTML:
<body> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" Text="Inner" OnClick="Button1_Click" /> </div> <div id="dynamic1"> </div> <div id="dynamic2" runat="server"> </div> </form> </body>
C#:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class Test_tsInnerHTML : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { try { //Script string strScript = "document.getElementById('dynamic1').innerHTML='<input type=\"file\" name=\"FileUpload1\" id=\"FileUpload1\" />'"; ScriptManager.RegisterStartupScript(this, typeof(string), "Function", strScript, true); //Asp.net dynamic2.InnerHtml = Server.HtmlDecode("<Input type='file' name='fileupload2' id='fileupload2'>"); } catch (Exception) { throw; } } }
沒有留言:
張貼留言