Click here to Skip to main content
15,881,803 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Send value to server side Pin
Not Active5-Jun-11 2:23
mentorNot Active5-Jun-11 2:23 
GeneralRe: Send value to server side Pin
Elham M5-Jun-11 7:47
Elham M5-Jun-11 7:47 
GeneralRe: Send value to server side Pin
Not Active5-Jun-11 8:25
mentorNot Active5-Jun-11 8:25 
GeneralRe: Send value to server side Pin
Elham M6-Jun-11 0:55
Elham M6-Jun-11 0:55 
GeneralRe: Send value to server side Pin
Not Active6-Jun-11 1:52
mentorNot Active6-Jun-11 1:52 
GeneralRe: Send value to server side Pin
Morgs Morgan8-Jun-11 1:17
Morgs Morgan8-Jun-11 1:17 
GeneralRe: Send value to server side Pin
Elham M8-Jun-11 7:54
Elham M8-Jun-11 7:54 
GeneralRe: Send value to server side Pin
Morgs Morgan8-Jun-11 21:20
Morgs Morgan8-Jun-11 21:20 
Try this:
1. Default.aspx

<select id="sel1"><option>came here first!</option></select>
<select id="sel2"><option>came here second!</option></select>

<input id="send" type="button" value="Send Date" />
//anywhere in your default.aspx insert this:
    <asp:ScriptManager ID="test" runat="server">
        <Services>
            <asp:ServiceReference Path="test.asmx" />
        </Services>
    </asp:ScriptManager>


2. Your JS/SQuery

<script type="javascript/text">
    $(function(){
         if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();
         $('#send').click(function(){
               $sel1_value = $('#sel1').val();
               $sel2_value = $('#sel2').val();
               test.SendData($sel1_value, $sel2_value, SendSuccess, SendFailed);
          });
          function SendSuccess(result, eventArgs)
          {
              alert(result);
          }
          function SendFailed(error)
          {
              alert(error);//server side exception
          }
     });
</script>


3. Webservice (test.asmx)
- Create a new webservice called test.asmx
- Create a new [WebMethod] called SendData in this class like so:

//uncomment whatever you are asked to uncomment in this class
[WebMethod]
public string SendDate(string sel1, string sel2)
{
    //process your received data here using the passed parameters
    //care to return response if need be!
    return "...holla! i got here last!!!";
}


Oops!!! don't forget to download and reference the latest JQuery Library in your project!
Goodluck
GeneralRe: Send value to server side Pin
Not Active8-Jun-11 8:37
mentorNot Active8-Jun-11 8:37 
GeneralRe: Send value to server side Pin
Morgs Morgan8-Jun-11 21:20
Morgs Morgan8-Jun-11 21:20 
GeneralRe: Send value to server side Pin
Elham M8-Jun-11 7:44
Elham M8-Jun-11 7:44 
AnswerRe: Send value to server side Pin
shankysharma863-Jun-11 2:08
shankysharma863-Jun-11 2:08 
GeneralRe: Send value to server side Pin
Not Active3-Jun-11 4:48
mentorNot Active3-Jun-11 4:48 
QuestionStoring and Retrieving Documents in SQL Server Pin
Aptiva Dave2-Jun-11 10:53
Aptiva Dave2-Jun-11 10:53 
AnswerRe: Storing and Retrieving Documents in SQL Server Pin
Blue_Boy2-Jun-11 20:36
Blue_Boy2-Jun-11 20:36 
AnswerRe: Storing and Retrieving Documents in SQL Server Pin
thatraja2-Jun-11 23:28
professionalthatraja2-Jun-11 23:28 
QuestionListBox Pin
jashimu2-Jun-11 4:21
jashimu2-Jun-11 4:21 
AnswerRe: ListBox Pin
shankysharma862-Jun-11 4:27
shankysharma862-Jun-11 4:27 
GeneralRe: ListBox Pin
jashimu2-Jun-11 4:42
jashimu2-Jun-11 4:42 
GeneralRe: ListBox Pin
shankysharma862-Jun-11 4:46
shankysharma862-Jun-11 4:46 
GeneralRe: ListBox Pin
gavindon2-Jun-11 5:45
gavindon2-Jun-11 5:45 
AnswerRe: ListBox Pin
Monjurul Habib2-Jun-11 9:48
professionalMonjurul Habib2-Jun-11 9:48 
Questionplaceholder position Pin
C#Coudou1-Jun-11 23:16
C#Coudou1-Jun-11 23:16 
AnswerRe: placeholder position Pin
Blue_Boy2-Jun-11 3:19
Blue_Boy2-Jun-11 3:19 
AnswerRe: placeholder position Pin
Prasanta_Prince2-Jun-11 7:18
Prasanta_Prince2-Jun-11 7:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.