Send value to server side
-
Then make it so! Why are you making this more difficult on yourself?
I know the language. I've read a book. - _Madmatt
-
Because my combobox is not a server control, it's a html control so how can I bind data source to html control?!please guide me.
-
-
Because I want to do this in client side Not in server side client side is faster than server side Do you have any suggestion or not?
Elham M wrote:
client side is faster than server side
Not necessarily. There are many factors to consider. By hard coding values into the JavaScript you have reduced the maintainability and extensibility of the code and application making it more difficult on yourself and those that may follow. Knowing the proper tools and when to use them is the mark of a real developer not just a hobbyist or hacker. Which are you? You can easily get the values using JQuery
var menuVal = $("#menu").val();
var subMenuVal = $("#submenu").val();One way of passing them to a server method
Code-behind
[WebMethod]
public static void Foo(string menu, string subMenu)
{
...
}JavaScript
PageMethods.Foo( menuVal, subMenuVal);
I know the language. I've read a book. - _Madmatt
-
Elham M wrote:
client side is faster than server side
Not necessarily. There are many factors to consider. By hard coding values into the JavaScript you have reduced the maintainability and extensibility of the code and application making it more difficult on yourself and those that may follow. Knowing the proper tools and when to use them is the mark of a real developer not just a hobbyist or hacker. Which are you? You can easily get the values using JQuery
var menuVal = $("#menu").val();
var subMenuVal = $("#submenu").val();One way of passing them to a server method
Code-behind
[WebMethod]
public static void Foo(string menu, string subMenu)
{
...
}JavaScript
PageMethods.Foo( menuVal, subMenuVal);
I know the language. I've read a book. - _Madmatt
I hope this will help u, if not ask if u need further clarification (there is code here!). Otherwise use ajax to send you newely populated data back to the server.
-
Elham M wrote:
client side is faster than server side
Not necessarily. There are many factors to consider. By hard coding values into the JavaScript you have reduced the maintainability and extensibility of the code and application making it more difficult on yourself and those that may follow. Knowing the proper tools and when to use them is the mark of a real developer not just a hobbyist or hacker. Which are you? You can easily get the values using JQuery
var menuVal = $("#menu").val();
var subMenuVal = $("#submenu").val();One way of passing them to a server method
Code-behind
[WebMethod]
public static void Foo(string menu, string subMenu)
{
...
}JavaScript
PageMethods.Foo( menuVal, subMenuVal);
I know the language. I've read a book. - _Madmatt
-
I hope this will help u, if not ask if u need further clarification (there is code here!). Otherwise use ajax to send you newely populated data back to the server.
-
I hope this will help u, if not ask if u need further clarification (there is code here!). Otherwise use ajax to send you newely populated data back to the server.
Who were you responding to?
MorgSim wrote:
I hope this will help u
Hope what helps?
MorgSim wrote:
use ajax to send you newely populated data back to the server.
Brilliant! Exactly what I have suggested days ago.
I know the language. I've read a book. - _Madmatt
-
Try this: 1. Default.aspx
<select id="sel1"><option>came here first!</option></select>
<select id="sel2"><option>came here second!</option></select>//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
$(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 } });
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
-
Who were you responding to?
MorgSim wrote:
I hope this will help u
Hope what helps?
MorgSim wrote:
use ajax to send you newely populated data back to the server.
Brilliant! Exactly what I have suggested days ago.
I know the language. I've read a book. - _Madmatt
Mark Nischalke wrote:
Hope what helps?
Your suggestion