Click here to Skip to main content
15,886,798 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I have an asp.net application in which I am using kendo ui charts. I have a html table in the aspx page and I am storing the html td onclick value in a hiddenfield control like this,

XML
<table class="window" style="margin-top: 15px; text-align: center;">
      <tr id="NavMonth">
          <td id="m1" onclick="">
          Jan
          </td>
          <td id="m2" onclick="">
          Feb
          </td>
          <td id="m3" onclick="">
          Mar
          </td>
      </tr>
 </table>

<script type="text/javascript">
    $(document).ready(function () {
        $('.window td').on('click', function () {
            var idName = this.id;
            $('#hidden').val(idName);
        });
    });
</script>


Now I want to pass this hiddenfield value to a wcf service url so that I can show the charts as per the month selected by the user,

dataSource: {
     transport: {
              read: {
                        url: "http://<%=strWcfServer%>/WcfService1/Service1.svc/Total_Product_Count_Monthly?month=<%=month_number%>",
                        dataType: "json"
                    }
                }
            }


But this month_number variable has to be a global variable in the aspx.cs page and I have the month number in a hiddenfield.

How can I store this month_number value from hiddenfield to a global variable so that it can be passed to a wcf service or is there any other option to pass the selected month to the wcf service?

Thanks.
Posted
Updated 2-Feb-15 7:10am
v2
Comments
Neetin_1809 2-Feb-15 15:01pm    
Why Dont you Use DropDown ?Insead Prefer kendoDropDown Use OnSelect Event which will be far More Better.

You're missing the data: part for your datasource.

Here is an example:


dataSource: {
transport: {
read: {
url: "http://<%=strWcfServer%>/WcfService1/Service1.svc/Total_Product_Count_Monthly",
data: function () {
return {
month: $('#hidden').val();
};
}

dataType: "json"
}
}
}
 
Share this answer
 
Comments
Member 10986159 2-Feb-15 14:14pm    
I do not understand. I need to pass a month to the wcf service method.
Yes.

Under the hood, it will append "?month=1" to your endpoint querystring dynamically.

Try it :-)
 
Share this answer
 
Comments
Member 10986159 2-Feb-15 14:41pm    
Thank you very much for the answer but it is not working.
Are you using Fiddler? (you should be - it is invaluable in troubleshooting web dev).

What does Fiddler report as per any error?

What does your call string look like in Fiddler when executing that call?
 
Share this answer
 
Comments
Member 10986159 4-Feb-15 9:04am    
It says bad request.
VB
Using Fiddler, you need to determine what the exact querystring looks like to make sure it is properly formatted.

From there, you can also simulate the call yourself using Fiddler to make sure the problem does not lie elsewhere.
 
Share this answer
 
Comments
Deepu S Nair 5-Feb-15 7:57am    
Use 'Improve solution' link to update your solution.Otherwise it may attract downvoting

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900