newbie: communicating between javascript and c#

A

Anton

hi

asp.net 3.5

I have a webpage which have a 2 dropdownlists and several textboxes. The
dropdownlists are for selecting the font-size and font-color of the text in
the textboxes. (When storing content of the textboxes to the database I also
store font-size and font-color).

The problem is that when clicking on the textboxes I need to update the
dropdownlists with what I have previously selected for this textbox. I'm not
sure how to do that

any suggestions?
 
G

Guest

hi

asp.net 3.5

I have a webpage which have a 2 dropdownlists and several textboxes. The
dropdownlists are for selecting the font-size and font-color of the text in
the textboxes. (When storing content of the textboxes to the database I also
store font-size and font-color).

The problem is that when clicking on the textboxes I need to update the
dropdownlists with what I have previously selected for this textbox. I'm not
sure how to do that

any suggestions?

If you know what value must be selected in dropdownlists then you can
use something like this

<asp:textbox onclientclick="go()"....

<script>
var val = '<%=DbValue%>';

void go()
{
var x = getElementByID('<%=DropDownList1.ClientID%>');
for(i=0;i<x.length;i++)
{
if(x.options.value==val)
{
x.selectedIndex=i;
}
}
}

where go() is a js function to select value in DropDownList1; val can
be a database value (I supposed it can be a protected variable from
code behind)

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top