3 개의 ASP.NET 텍스트 상자와 하나의 HiddenField가 있습니다. 세 번째 텍스트 상자의 값 (비활성화 됨)은 다른 두 값의 값에 따라 다릅니다.비활성화 된 ASP.NET 텍스트 상자 값 검색
수식 txtPricePad의 초기 값이 0이라고 가정
txtPricepad = txtPrice/txtCarton
<asp:TextBox ID="txtPriceCase" runat="server" onblur="javascript:GetPricePerPad();></asp:TextBox>
<asp:TextBox ID="txtCarton" runat="server"></asp:TextBox>
<asp:TextBox ID="txtPricePad" Enabled="false" runat="server" ></asp:TextBox>
<asp:HiddenField ID="hdPricepad" runat="server"/>
function GetPricePerPad()
{
var priceCase = document.getElementById('ctl00_content_txtPriceCase').value;
var cartons = document.getElementById('ctl00_content_txtCarton').value;
var res = Number(priceCase)/Number(cartons);
document.getElementById('ctl00_content_txtPricePad').value = res;
document.getElementById('ctl00_content_hdPricepad').value = res;
}
이고 txtPrice의 값이 변화 될 때 txtCarton 12. 이고 1200이면 GetPricePerPad()가 호출되므로 txtPricePad는 100이됩니다.
자바 스크립트가 성공적으로 변경되었습니다. txtPricePad의 값을 100으로 지정하지만 codebehind에서 txtPricePad를 호출 할 때 해당 값은 여전히 0입니다. 그 이유는이 수식의 결과를 HiddenField에 할당 한 이유입니다. 이것을 할 수있는 다른 방법이 있습니까? 나는 HiddenField를 다시 사용하고 싶지 않다.
[다음 jsp에서 사용할 수없는 텍스트 상자의 값을 가져오고 싶지만 null 값을 얻고 싶습니다.] (http://stackoverflow.com/questions/3757806/i-want-to- get-the-value-of-disabled-text-box-in-our-next-jsp-but-i-am-getting-nu) –