views:

229

answers:

2

Hi,

In my .ascx page there was some javascript functions.I want to send the value from this java script function to the codebehind file to execute a method.

I tried to use PageMethods but it was getting errors.As i google about this problem i found that PageMethods cannot use with .ascx control pages it can be only used with .aspx pages.

Please give me some suggestion how could i perform my task..

A: 

The simplest way seems to be is to refactor the functionality you want to run into an aspx page (as you can use pagemethods) and call it using javascript.

TheVillageIdiot
Thanks for your reply,Actually i need to store the search values from URL into database.I am thinking that i will store this from javascript as a cookie and then retrieve the cookie from c# code and save it as a string in database.Do u thik it works
@Subha if you are just storing search values from URL then will not it be better to **extract** them from **query string** and push to db when you search, rather than going all the trouble of using cookies?
TheVillageIdiot
A: 

Try using a webservice instead of pagemethods. Check out the msdn doc it has a pretty decent example.

Mcbeev