|
gus;
I am creating an ajax control called 'AsyncScedular ' that has a HashTable property. so, I decided to add the key-value pairs in a startup script block. this would be renderd as:
Sys.Application.initialize();
Sys.Application.add_init(function() {
$create(AjaxServerControl1.AsyncScedular, {"LogMethod":"WriteLog"}, null, null, $get("ctl00_AsyncScedular1"));
});
$find('ctl00_AsyncScedular1').prioritytable['ctl00$ContentPlaceHolder1$Button2'] = AjaxServerControl1.Priority.AboveNormal;
$find('ctl00_AsyncScedular1').prioritytable['ctl00$ContentPlaceHolder1$Button3'] = AjaxServerControl1.Priority.Normal;
$find('ctl00_AsyncScedular1').prioritytable['ctl00$ContentPlaceHolder1$Button1'] = AjaxServerControl1.Priority.High;
$find('ctl00_AsyncScedular1').prioritytable['ctl00$ContentPlaceHolder1$Button6'] = AjaxServerControl1.Priority.RealTime;
$find('ctl00_AsyncScedular1').prioritytable['ctl00$ContentPlaceHolder1$Button4'] = AjaxServerControl1.Priority.Low;
$find('ctl00_AsyncScedular1').prioritytable['ctl00$ContentPlaceHolder1$Button5'] = AjaxServerControl1.Priority.BelowNormal;
But when I execute the page I get a null refertence retuned from $find() function. but after the page get loaded $find('ctl00_AsyncScedular1') returns a reference of type object .
I am wondering if you could help me with this.
Help people,so poeple can help you.
|
|
|
|
|
Wait for the page to be ready before you try this. You can use the
$(document).ready method to hook into this here.
|
|
|
|
|
Sir;
do you mean JQuery?!!
Look at this[^]
Help people,so poeple can help you.
|
|
|
|
|
I do, and did it really need 2 exclamations as well?
|
|
|
|
|
Not in the ordenary cases, but i was surprised.
Actually, i hate JQuery, you should understand this.
100
Help people,so poeple can help you.
|
|
|
|
|
Ali Al Omairi(Abu AlHassan) wrote: Actually, i hate JQuery, you should understand this.
Why should I understand this? It's your life and your preferences. It has zero impact on me.
|
|
|
|
|
do you really think so?!!
I am sorry.. Iam not crying, it's just the rain;
Help people,so poeple can help you.
|
|
|
|
|
Suppose I have following table in my database:
Tbl_Persons:
Id Country Name
1 Australia Ben
2 Japan John
3 Korea Libby
4 Australia Raymond
I use following Query and bind the result using `DataTable` to a `Gridview`.
select id,Country,Name
from tbl_persons
where country='Australia'
In `gridview` I have two `Bound Columns` and 1 `template column`.
In template column I typically put an `ImageButton` and assign the `ID field` to `image button` using `Command Argumnet property`. And when user clicks on the `imagebutton` in the browser I'll get the `command argument value` in sever an do some operations with it.
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:BoundField DataField="ountry" HeaderText="Country" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server"
CommandArgument='<%# Eval("Id") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
As you know in runtime mode when user views the source of code in browser the values of `command argument` are not observable because they create in server. and user can't change the values using the browser and send the changed values to the server.
But `gridview` is server side an has post back. So I use `jquery` and fill `My gridview` with appending `tr` and `td` tags in client side.
For `ID field of my database` because I don't have `command argument` in client side I assign the `Id` of each `TD` tag equals to the `Id field`.
But the user can change the `Id values` in the browser and send invalid data to the server and this is a disaster.
This is piece of my code:
script type="text/javascript">
function BindGridView() {
$.ajax({
type: "POST",
url: "Default.aspx/GetNames",
data: "{}",
contentType: "application/json",
dataType: "json",
success: function (data) {
for (var i = 0; i < data.d.length; i++) {
$("#NamesGridView").append("<tr><td id="+data.d[i].Id+">" + data.d[i].Country +
"</td><td>" + data.d[i].Name + "</td></tr>");
}
}
})
}
</script>
So what can I do to prevent user to changes the values?
Are there any ways something like Command Argument in client side?
|
|
|
|
|
Sir;
I don't know why did you use jquery; you can do it easier using update panels[^]
Help people,so poeple can help you.
|
|
|
|
|
I don't use update panel because of it's speed. it's slow specially when I upload it in internet and the speed is slow.
|
|
|
|
|
i just want to refresh datalist in asp:panel. not want refresh whole page.....????
|
|
|
|
|
Hi,
You can use Update Panel Control. It is 1 of the ajax control already included in your ajax controls no other ajax kit is required for that
|
|
|
|
|
i m using update panel. but problem is that i have auto refresh on page after every 5sec. so i just want that only datalist refresh not whole page
|
|
|
|
|
I guess this link[^] will help you.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
|
Hi
I have an Interdependent select menus allow you to populate one select menu based on a choice made in another select menu in javascript. For example, a menu of cities might change based on the state that was selected in another menu .my problem is I can't access the value of menu in server side because I want to insert this value in database but when I write runat="server" in select tag it doesen't work correctly what can I do to get the value of this menu in asp please help me?
Regards
|
|
|
|
|
Elham M wrote: it doesen't work correctly
We need a little more than this. What is the observed behavior? What doesn't work?
You could gather the data on the client side (JavaScript) and call and ajax method to push it to the server. Or you could, using JavaScript again, store the selected menu values in a hidden field.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I've didn't work with ajax method How can I call it to push to the server?
this is my code:
<asp:content id="Content1" contentplaceholderid="head" runat="Server">
var MENU = [];
MENU[0] = [];
MENU[1] = [];
MENU[0][0] = new Option("New York", "NY");
MENU[0][1] = new Option("New York City", "NYC");
MENU[0][2] = new Option("Syracuse", "SYR");
MENU[1][0] = new Option("California", "CA");
MENU[1][1] = new Option("Los Angeles", "LAN");
MENU[1][2] = new Option("San Diego", "SDI");
function populateMain(mainSel, subSel) {
var mainMenu = mainSel;
var subMenu = subSel;
mainMenu.options.length = 0;
for (var i = 0; i < MENU.length; i++) {
mainMenu.options[i] = MENU[i][0];
}
populateSub(mainMenu, subMenu);
}
function populateSub(mainSel, subSel) {
var mainMenu = mainSel;
var subMenu = subSel;
var optMainMenu;
subMenu.options.length = 1;
optMainMenu = mainMenu.selectedIndex;
for (var i = 1; i < MENU[optMainMenu].length; i++) {
subMenu.options[i] = MENU[optMainMenu][i];
}
}
<asp:content id="Content2" contentplaceholderid="ContentPlaceHolder1" runat="Server">
--Please Choose--
////////////On server side
protected void Page_Load(object sender, EventArgs e)
{
const string someScript = "alertMe";
if (!ClientScript.IsStartupScriptRegistered(this.GetType(), someScript))
{
ClientScript.RegisterStartupScript(this.GetType(),
someScript, "populateMain(document.getElementById('State'), document.getElementById('City'));", true);
}
}
I can't get the value of menu in server side!I wan't to save them in database so what's your sugestion?
|
|
|
|
|
Now we can see what you are doing. Of course you can't get the value in the code behind because you are setting the values on the client side, the server knows nothing about this. You would be better off binding the combobox to a data source, it doesn't have to be a data table or dataset, any collection will do.
What you appear to be attempting to do is called a cascading drop down and there are multiple sources available if you look.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
But how can I bind this combobox to a data source!!? Do you see my code? my combobox isn't a component
|
|
|
|
|
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.
|
|
|
|
|
Once again. Why must it be an html control? Why are you making it difficult on yourself, and us, by not using ASP.NET controls in an ASP.NET application?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
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
|
|
|
|