|
|
#1 |
|
Frenzied Member
Join Date: Nov 02
Location: Karachi
Posts: 1,267
![]() |
How to use server control in JavaScript
Hello everybody,
I need to use my server controls in javascript for client-side validation etc. I have a listbox control. <asp:listbox id=groupsListBox runat="server" Width="256px" OnSelectedIndexChanged="javascript:SetTextBox();"></asp:listbox> As user selects a value, I need to display this value in the TextBox just below the listbox. I wrote the code in SetTextBox() but this function does not execute. Thanks.
__________________
The secret of creativity is knowing how to hide your sources... |
|
|
|
|
|
#2 |
|
Member
Join Date: Mar 05
Posts: 56
![]() |
Re: How to use server control in JavaScript
Well i've never used OnSelectedIndexChanged before, but what happends if you use the onChange event? This is the html of an example I made that works:
VB Code:
Good Luck; |
|
|
|
|
|
#3 |
|
Frenzied Member
Join Date: Nov 02
Location: Karachi
Posts: 1,267
![]() |
Re: How to use server control in JavaScript
Thanks. It resolved my problem. I have two more questions.
My listbox is databound, and I have used DataTextField and DataValueField properties. When I get the value of ListBox in JavaScript function, it gives me DataValueField. I need to get the SelectedText of the listbox control. Code:
thisList.DataSource = dtTemporary; // Bind with DataTable thisList.DataTextField = "Name"; thisList.DataValueField = "ID"; thisList.DataBind(); Code:
<asp:ImageButton id="deleteImageBox" runat="server" ImageUrl="images\btn_delete_off.gif" BorderStyle="None" OnClick='javascript:btnDelete_Click();'></asp:ImageButton>
__________________
The secret of creativity is knowing how to hide your sources... |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|