Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 9th, 2014, 10:14 PM
Registered User
 
Join Date: Jul 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default hidden field in code behind not refreshing

// problem refreshing value. code behind file dynamically creates a checkbox, aspx file contains javascript that is invoked when the checkbox is checked see below:

//javascript

function checkBoxClicked(sender)
{
var hdnfldVariable = document.getElementById('hcompare');

if (sender.checked == true) {
sCompareAuditVersion = sender.value;
}
document.getElementById('hcompare').value = sCompareAuditVersion;
}

//aspx file - I have used a hidden field to pass to code behind file and have initialize value with 'x' to ensure that value changes

<form id="form1" runat="server">
<div class="lowSectionClass">
<asp:HiddenField id="hcompare" value="X" runat="server">
</asp:HiddenField>

//code behind file dynamically builds chekbox

public class Report : Page
{
protected HiddenField hcompare;

private string populateCalculations(int tabID, int programID, int participantID)
{
string str = "";
str = ((((str + "<br /><br /><center><table cellpadding='0' cellspacing='10'>" + "<tr class='HeadingCellText'>") + "<td>Audit Version</td>" + "<td></td>") + "<td>Calculation Set</td>" + "<td></td>") + "<td>Run Calcs/Print Report/Print CSB</td>" + "<td></td>") + "<td>Compare?</td>" + "</tr>";
DataTable infoList = new DataTable();
infoList = new ReportClass().GetInfoList(programID);
if (infoList.Rows.Count > 0)
{
for (int i = 0; i < infoList.Rows.Count; i++) // 1 = a audit, 2 = b audit, 3 = c audit.....
{
if ((i % 2) == 0) //audit 'a' = 0, audit 'b' = 1
{
str = string.Concat(new object[] { str, "<td>", infoList.Rows[i]["dtCalcDate"], "</td>" }) + "<td></td>";
str = string.Concat(new object[] { str, "<td><a href=\"javascript:runCalcs('", programID, "','", infoList.Rows[i]["sAuditVersion"].ToString(), "');\">Run Calcs</a> | <a href=\"javascript:setPrintVariables(", programID, ",", participantID, ",'",
infoList.Rows[i]["sAuditVersion"].ToString(), "');section_CallBack('build');\">Print Report</a> | <a href=\"ReportViewer.aspx?ProgramID=", programID, "&ParticipantID=", participantID, "&AuditVersion=",
infoList.Rows[i]["sAuditVersion"].ToString(),"&CompareAuditVersion=", hcompare.Value,"&csb=1\" target='blank'>Print CSB</a></td>"
}) + "<td></td>";
// above is where the hidden field is assigned to be passes in as a parameters and the value is not being updated
// below is where the checkbox is created and assigned function 'checkBoxClicked(this)'
str = string.Concat(new object[] { str, "<td><input id='Checkbox", i, "' tabindex='", i, "' value='", infoList.Rows[i]["sAuditVersion"].ToString(), "' onclick='checkBoxClicked(this)' type='checkbox' /></td>" }) + "</tr>";
}
}
}
return (str + "</tfoot>" + "</table></center>");
 
Old July 9th, 2014, 11:04 PM
Registered User
 
Join Date: Jul 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default While increasing the good calories using strategic

While increasing the good calories using strategic system that takes into account how your body processes certain nutrients more on this in a bit number four you’re not seeing results for all the effort you're putting for if you've ever done a week or two on any diet and didn't see significant results you are probably golden ready to throwing the towel so that you could find something else that works no one can blame you for that you see most diets fail because there simply aren’t enough rewards to keep up with all the sacrifices that need to be made and this is a key component of the three-week diet as my system is the only diet that I know of that focuses solely on producing extremely rapid results from my experience I found that for a diet to be ultra successful there must be a significant amount of rewards to go along with the effort you put forth you see when you wake up in the morning to find yourself one to two pounds lighter than you were just hours ago it tends to provide you with some serious motivation to keep on doing what you're doing this is one of the reasons that the week diet has been so successful for so many people and believe me when you see yourself drop just one pound of body fat in just one day you can visualize that in just nine more days you'll be carrying around pounds less have ugly fat around .

For more information, visit our site >>>>>>> http://eeaith.com/
 
Old August 3rd, 2014, 02:09 AM
Friend of Wrox
 
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts
Default

I am not understanding why you have declared a hidden field in your page definition. typically when add an asp.net control to a page it is added for you in the designer cs in visual studios, are you using something different?


I am not sure what your function does, but, as a simpler solution since you are doing this work on post back, just use the the selected value of the check box in the "populateCalculations" method. i.e.

infoList.Rows[i]["sAuditVersion"].ToString(),"&CompareAuditVersion=", yourCheckBox.SelectedValue,"&csb=1\" target='blank'>Print CSB</a></td>"


if you are trying to fill a table with some tablular data might I also suggest using a repeater and binding to it.

Code:
<asp:Repeater ID="repeater" runat="server" >
    <HeaderTemplate>
        <table>
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <td>
                <asp:Label ID="lblSomeLableName" runat="server" Text='<%# Eval("SomePropertyOrFieldName") %>' />
            </td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>       
        </table>
    </FooterTemplate>
</asp:Repeater>

Last edited by mmorgan30; August 3rd, 2014 at 02:12 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
pass value to the hidden field Dejitan ASP.NET 1.0 and 1.1 Basics 4 December 21st, 2006 03:13 AM
Hidden Field value error - PLEASE HELP jroxit Classic ASP Basics 5 September 18th, 2006 05:46 AM
Hidden field ashoka_klt ASP.NET 1.0 and 1.1 Basics 1 September 6th, 2006 07:12 AM
Validating a hidden field mkerchenski ASP.NET 1.0 and 1.1 Basics 1 June 3rd, 2004 11:20 AM
How to assign a value to a hidden field? Edward King Javascript How-To 1 May 3rd, 2004 07:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.