Newbie - Desperate for help

D

Debralous

What I want to do seems so simple, yet I can't figure it out! I have
a very simple aspx page that I'm displaying in an Iframe. The page
has three dropdown boxs and I this code on the aspx.cs to set three
variables to the selected text.

public partial class _Default : System.Web.UI.Page
{
public static string SelectedTopSector;
public static string SelectedSubSector;
public static string SelectedFinalSector;

protected void TopSector_SelectedIndexChanged(object sender,
EventArgs e)
{
SelectedTopSector = TopSector.SelectedItem.Text;
}
protected void SubSector_SelectedIndexChanged(object sender,
EventArgs e)
{
SelectedSubSector = SubSector.SelectedItem.Text;
}
protected void FinalSector_SelectedIndexChanged(object sender,
EventArgs e)
{
SelectedFinalSector = FinalSector.SelectedItem.Text;
}
}

I want to access these variables from javascript in order to pass the
values back to my parent form. My code is correct (see below) for
passing the variable back as I can pass static values, but I cannot
seem to figure out how to get pass the variables from the C# code.

<script type="text/javascript" language="javascript">
// Assign back to the form
parent.document.forms[0].all.topsector.DataValue =
SelectedTopSector;
parent.document.forms[0].all.subsector.DataValue =
SelectedSubSector;
parent.document.forms[0].all.finalsector.DataValue =
SelectedFinalSector;
</script>

PLEASE PLEASE PLEASE if someone could help me understand what I'm
missing I would appreciate it tremendously!!

Debra
 
G

Guest

The problem is that you're setting server side variables, and then accessing
them via javascript (client side). Remove the event handlers, (you dont need
them), and just pass the values back by accessing the dropdown values
directly in javascript.
 
D

Debralous

The problem is that you're setting server side variables, and then accessing
them via javascript (client side). Remove the event handlers, (you dont need
them), and just pass the values back by accessing the dropdown values
directly in javascript.



Debralous said:
What I want to do seems so simple, yet I can't figure it out! I have
a very simple aspx page that I'm displaying in an Iframe. The page
has three dropdown boxs and I this code on the aspx.cs to set three
variables to the selected text.
public partial class _Default : System.Web.UI.Page
{
public static string SelectedTopSector;
public static string SelectedSubSector;
public static string SelectedFinalSector;
protected void TopSector_SelectedIndexChanged(object sender,
EventArgs e)
{
SelectedTopSector = TopSector.SelectedItem.Text;
}
protected void SubSector_SelectedIndexChanged(object sender,
EventArgs e)
{
SelectedSubSector = SubSector.SelectedItem.Text;
}
protected void FinalSector_SelectedIndexChanged(object sender,
EventArgs e)
{
SelectedFinalSector = FinalSector.SelectedItem.Text;
}
}
I want to access these variables from javascript in order to pass the
values back to my parent form. My code is correct (see below) for
passing the variable back as I can pass static values, but I cannot
seem to figure out how to get pass the variables from the C# code.
<script type="text/javascript" language="javascript">
// Assign back to the form
parent.document.forms[0].all.topsector.DataValue =
SelectedTopSector;
parent.document.forms[0].all.subsector.DataValue =
SelectedSubSector;
parent.document.forms[0].all.finalsector.DataValue =
SelectedFinalSector;
</script>
PLEASE PLEASE PLEASE if someone could help me understand what I'm
missing I would appreciate it tremendously!!
Debra- Hide quoted text -

- Show quoted text -

Can you give me any direction on accessing the value from javascript?
I have tried using getelementbyid and I just get an objectrequired
error.

Thanks!
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top