newbie: communicating between javascript and c#

  • Thread starter Thread starter Anton
  • Start date Start date
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?
 
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
 
Back
Top