Здравствуйте, thest, Вы писали:
Чего-то не работает.
На форму вставил <asp:HiddenField id="HiddenField1" runat=server />.
Упрстил все до безобразия. Функия в скрипте по клику на картинке отрабатывает (видно по сообщению):
function setcheckitem(i)
{
alert("клик " + i);
array_string = "my string";
document.getElementById(<%=HiddenField1.ClientID %>).Value=array_string;
}
потом на кнопке:
protected void ClickItem(object sender, EventArgs e)
{
string str = HiddenField1.Value.ToString();
//str = null ?
}
HiddenField1.Value — пусто. Не могу понять почему?
Вот сама страница (в сокращении):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head> <script language="JavaScript" type="text/javascript">
function setcheckitem(i)
{
alert("клик " + i);
array_string = "my string";
document.getElementById(ctl00_HiddenField1).Value=array_string;
}
</script>
</head>
<body>
<form name="aspnetForm" method="post" action="question.aspx" id="aspnetForm">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEwMDUyNjYzMjhkZPrS1ANEydFjslrm/7ulT1CpKmok" />
</div>
<input type="hidden" name="ctl00$HiddenField1" id="ctl00_HiddenField1" />
<div>
<table id="QueList" border="1" cellspacing="2" cellpadding="10" style="width:660px;">
<tr id="row1"><td>ffffff</td><td><img id="img0" src='default.gif' OnClick='setcheckitem(0)' /></td></tr>
<tr id="row2"><td>aaaaaa</td><td><img id="img1" src='default.gif' OnClick='setcheckitem(1)' /></td></tr>
</table>
</div>
<input type="submit" name="ctl00$ClickItem" value="далее" id="ctl00_ClickItem" />
form>
</body>
</html>
Где-то ошибся, но вот где?