Hi Mark,
Thanks for posting in the community!
From your description, you used some HtmlInputText controls(set ast
runat=server) on an ASP.NET web page. However, you found that when you
posted back the page, the values in the HtmlInputText Control can't remain,
will return back to the original value, yes?
If there is anything I misunderstood, please feel free to let me know.
As for this problem, I'd like to confirm some further things on it:
1.You mentioned that when you input a value "2" in the html textbox and
post back the page, after that the value returned to "1", yes? Are you sure
there is no other code in codebehind will modify the textbox's value?
2.As you mentioned, you tested use the numeric value such as "1","2". Have
you tried using string value. For example, put a string like "Hello World"
and post back to see whether this remains?
3.I still feel this problem a bit strang, would you please try creating
another new project and do the same test in it? Also, do be sure that you
have'nt disable the ViewState of the page at PageLevel(@Page directive) or
Application Level(web.config) or ..
And here is a example page I used to test, maybe you can also try testing
on this page to see whether the problem remains:
-----------------------------------aspx
pape--------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>TestValue</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="
http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="500" align="center">
<tr>
<td><INPUT id="txtHtml" type="text" name="txtHtml" runat="server"></td>
</tr>
<tr>
<td><INPUT id="btnHtml" type="button" value="Html Button"
name="btnHtml" runat="server">
<asp:Button id="Button1" runat="server" Text="ASP.NET
Button"></asp:Button></td>
</tr>
</table>
</form>
</body>
</HTML>
-----------------------------code behind page class-------------------------
Public Class TestValue
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents txtHtml As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents btnHtml As
System.Web.UI.HtmlControls.HtmlInputButton
'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub btnHtml_ServerClick(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnHtml.ServerClick
Response.Write("<br>txtHtml's value is " & txtHtml.Value)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Response.Write("<br>txtHtml's value is " & txtHtml.Value)
End Sub
End Class
-----------------------------------------------------------
Please try out the preceding suggestions. If you feel any thing unclear or
need any help, please feel free to post here.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)