ASP.Net and client side control (SelectedIndexChanged)

  • Thread starter Thread starter Geordie
  • Start date Start date
G

Geordie

I was wondering what capabilities ASP.Net has at the client level.

I have been using a RadioButtonList.

My control and additional textboxes look like this:

o See item number [ ]
o See items from Date [ ] to date [ ]

I have the method defined for SelectedIndexChanged event. Basically,
I am trying to clear and disable the text selections for the
unselected item.

Example:

private void RadioButtonList1_SelectedIndexChanged(object sender,
System.EventArgs e)
{

if (RadioButtonList1.SelectedValue.ToString() == "ItemNumber")
{

txtFromDate.Text = "";
txtToDate.Text = "";
txtFromDate.Enabled = false;
txtToDate.Enabled = false;
txtItemNumber.Enabled = true;

}
}

The problem is that my SelectedIndexChanged event does not fire until
the post. I can set the AutoPost=True, but this is still doing a
post. That seems like a lot of traffic (back to the server and
running code again, etc) just to disable some client level fields. I
should be able to do this all on the client because the server does
not need to know this information.

Well, I could fall back by writing some JScript to do this for me, but
I thought there would be a native way for ASP.Net to handle this.

Does anyone have any ideas?

Thanks in advance!
 
If you dont want to post back then, client side JScript is the only option
you have.
 
Another option is to use HTML Radio Buttons.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

Vaibhav said:
If you dont want to post back then, client side JScript is the only option
you have.

Geordie said:
I was wondering what capabilities ASP.Net has at the client level.

I have been using a RadioButtonList.

My control and additional textboxes look like this:

o See item number [ ]
o See items from Date [ ] to date [ ]

I have the method defined for SelectedIndexChanged event. Basically,
I am trying to clear and disable the text selections for the
unselected item.

Example:

private void RadioButtonList1_SelectedIndexChanged(object sender,
System.EventArgs e)
{

if (RadioButtonList1.SelectedValue.ToString() == "ItemNumber")
{

txtFromDate.Text = "";
txtToDate.Text = "";
txtFromDate.Enabled = false;
txtToDate.Enabled = false;
txtItemNumber.Enabled = true;

}
}

The problem is that my SelectedIndexChanged event does not fire until
the post. I can set the AutoPost=True, but this is still doing a
post. That seems like a lot of traffic (back to the server and
running code again, etc) just to disable some client level fields. I
should be able to do this all on the client because the server does
not need to know this information.

Well, I could fall back by writing some JScript to do this for me, but
I thought there would be a native way for ASP.Net to handle this.

Does anyone have any ideas?

Thanks in advance!
 

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

Back
Top