0

Within a webform I have a jquery datepicker that is bound to text field in the ui which in turn is bound to a hidden field (asp hidden field not html)

<div class="dateContainer">
     <span class="fbSmallLabel">Start Date</span>
        <input id="txtStartDate" class="datequeryterm" type="text" value="<%= ((HiddenField)Parent.FindControl("hdnStartDate")).Value %>" />
 </div>

When a date is selected the hndfield is updated which then updates the value in the textbox

$("#btnApplyFilter").click(function () {
        setFilterFields();
        $.modal.close();
    }); 

function setFilterFields() {       
        var startDate = $("#txtStartDate").val();
        var endDate = $("#txtEndDate").val();

        $("#hdnStartDate").val(startDate);
        $("#hdnEndDate").val(endDate);
    }

Using firebug or IE dev tools I can see that the hidden field is updated in the DOM however when I reference the hidden field from the webform I get a null "" value.

protected void SetSearchFilterData()
{
   DateTime dt;
   string StartDate = hdnStartDate.Value;
   string EndDate = hdnEndDate.Value;

   if (DateTime.TryParse(StartDate, out dt))
   {           
     srchRequest.DateRangeStart = DateTime.Parse(StartDate);
   }

   if (DateTime.TryParse(EndDate, out dt))
   {   
     srchRequest.DateRangeEnd = DateTime.Parse(EndDate);
   }
}

The method is a bit basic as I was trying to explicitly see what was happening with the variable assignment. Previously I was declaring the start date and end date in the following manner

public string StartDate
{
  get { return hdnStartDate.Value; }
  set { hdnStartDate.Value = value; }
}

While this did detect the field the value continues to be null.

Any suggestions would be appreciated

-cheers

4

1 回答 1

0

您发布的一个input标签没有name所以它不会提交任何表单数据

于 2012-10-29T21:01:02.427 回答