0

次のように、javascript で asp textbox に値を割り当てています。

var tempStorytxt = document.getElementById("<%=txtStory.ClientID%>");
tempStorytxt.Value = TempValue;
alert(tempStorytxt.Value);

しかし、次のようにコードビハインドでアクセスすると、txtStoryには何もありません

 int StoryId = int.Parse(txtStory.Text);
4

3 に答える 3

0

これを試して;

<asp:Button ID="btnTest" runat="server" OnClientClick="setVal()" OnClick="btnTest_Click" Text="Test" />

あなたのjs関数;

 function setVal()
 {
   var tempStorytxt = document.getElementById("<%=txtStory.ClientID%>");
   tempStorytxt.setAttribute("value", tempValue);
   alert(tempStorytxt.getAttribute("value"));
 }

およびボタンクリックイベントで。

 int StoryId = int.Parse(txtStory.Text);
于 2013-04-11T15:03:13.427 に答える
0

txtStorytxt.Value ではなく、 txtStorytxt.valueとして小さい V を使用します。

于 2013-04-11T14:35:26.310 に答える