anyway to do this without post back to server

Hi I have a dropdown box with entries like

AY Activity Yellow
AB Activity Blue
AR Activity Red

This dropdown is followed by two text boxes and when the user selects AY I
would like to display the following in the text boxes

txbx1 [AY] txbx2 [Activity Yellow]
for AB Activity Blue
txbx1 [AB] txbx2 [Activity Blue]
So I am just spliting the string and displaying portions in each text box.
I was just wondering if there is a way to do this without posting back the
server on the dropdown SelectedIndexChanged event?
Thanks

--
Paul G
Software engineer.
Paul [ Fr, 11 April 2008 23:08 ] [ ID #1940231 ]

RE: anyway to do this without post back to server

yes, its simple javascript.

<script>
function doDropChange(e)
{
var txt1 = document.getElementById('<%=txt1.ClientID%>');
var txt2 = document.getElementById('<%=txt2.ClientID%>');
txt1.value = e.value.substr(0,2);
txt2.value = e.value.substr(3);
}
</script>

then in codebehind:

myDropDowm.Attributes["onchange"] = "doDropChange(this)";


-- bruce (sqlwork.com)


"Paul" wrote:

> Hi I have a dropdown box with entries like
>
> AY Activity Yellow
> AB Activity Blue
> AR Activity Red
>
> This dropdown is followed by two text boxes and when the user selects AY I
> would like to display the following in the text boxes
>
> txbx1 [AY] txbx2 [Activity Yellow]
> for AB Activity Blue
> txbx1 [AB] txbx2 [Activity Blue]
> So I am just spliting the string and displaying portions in each text box.
> I was just wondering if there is a way to do this without posting back the
> server on the dropdown SelectedIndexChanged event?
> Thanks
>
> --
> Paul G
> Software engineer.
brucebarker [ Sa, 12 April 2008 00:09 ] [ ID #1941078 ]

RE: anyway to do this without post back to server

Thanks it works. For the code behind I used
if (!Page.IsPostBack)
{
this.dropdown.Attributes["onchange"] = "doDropChange(this)";
}
--
Paul G
Software engineer.


"bruce barker" wrote:

> yes, its simple javascript.
>
> <script>
> function doDropChange(e)
> {
> var txt1 = document.getElementById('<%=txt1.ClientID%>');
> var txt2 = document.getElementById('<%=txt2.ClientID%>');
> txt1.value = e.value.substr(0,2);
> txt2.value = e.value.substr(3);
> }
> </script>
>
> then in codebehind:
>
> myDropDowm.Attributes["onchange"] = "doDropChange(this)";
>
>
> -- bruce (sqlwork.com)
>
>
> "Paul" wrote:
>
> > Hi I have a dropdown box with entries like
> >
> > AY Activity Yellow
> > AB Activity Blue
> > AR Activity Red
> >
> > This dropdown is followed by two text boxes and when the user selects AY I
> > would like to display the following in the text boxes
> >
> > txbx1 [AY] txbx2 [Activity Yellow]
> > for AB Activity Blue
> > txbx1 [AB] txbx2 [Activity Blue]
> > So I am just spliting the string and displaying portions in each text box.
> > I was just wondering if there is a way to do this without posting back the
> > server on the dropdown SelectedIndexChanged event?
> > Thanks
> >
> > --
> > Paul G
> > Software engineer.
Paul [ Sa, 12 April 2008 00:38 ] [ ID #1941079 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » anyway to do this without post back to server

Vorheriges Thema: ASP.NET VB.NET Login page using Access db
Nächstes Thema: GridView / EditItemTemplate: using with disconnected DataTable?