passing data on the cleint side

Discussion in 'ASP .Net Web Controls' started by Phil Barber, Jul 18, 2006.

  1. Phil Barber

    Phil Barber Guest

    I have dropdown list I want to let the user pick an item in the list and add
    it to text box.
    It works all fine as long as I set the Autopostback on the dropdown list.
    the only problems I have is the speed of page as it is being redrawn on
    every selection.
    my question is there a way to move the selection to the text box on the
    client side without the trip to the server?

    this is the code behind the dropdiwn list:
    protected void CmbClaimPrefix_SelectedIndexChanged(object sender,EventArgs
    e)

    {


    if (TxtCvgNum.Text=="ALL")

    TxtCvgNum.Text=CmbCvgNum.SelectedValue;

    else

    TxtCvgNum.Text+=","+CmbCvgNum.SelectedValue;

    }
     
    Phil Barber, Jul 18, 2006
    #1
    1. Advertising

  2. hi Phil,
    you can try to do it exclusively in clientside js, this way you wont need to
    postback un-necessarily.
    In the following code i pasted below, replace 'TextBox1' with the id of your
    textbox.
    Regards,
    Alessandro Zifiglio
    http://www.AsyncUI.net

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!this.IsPostBack)
    {
    this.DropDownList1.Attributes.Add("onchange",
    "document.getElementById('TextBox1').value =
    this.options[this.selectedIndex].value;");
    }
    }


    "Phil Barber" <> ha scritto nel messaggio
    news:...
    >I have dropdown list I want to let the user pick an item in the list and
    >add it to text box.
    > It works all fine as long as I set the Autopostback on the dropdown list.
    > the only problems I have is the speed of page as it is being redrawn on
    > every selection.
    > my question is there a way to move the selection to the text box on the
    > client side without the trip to the server?
    >
    > this is the code behind the dropdiwn list:
    > protected void CmbClaimPrefix_SelectedIndexChanged(object sender,EventArgs
    > e)
    >
    > {
    >
    >
    > if (TxtCvgNum.Text=="ALL")
    >
    > TxtCvgNum.Text=CmbCvgNum.SelectedValue;
    >
    > else
    >
    > TxtCvgNum.Text+=","+CmbCvgNum.SelectedValue;
    >
    > }
    >
    >
     
    Alessandro Zifiglio, Jul 18, 2006
    #2
    1. Advertising

  3. Phil Barber

    Phil Barber Guest

    first I would like to say thanks that does work. I do still have one problem
    when I examine the text box in code the values that were added by the
    dropdown list are not in the text property of the text box, even though they
    show on the screen just fine!

    any ideas
    thanks
    phil

    "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote in
    message news:e%...
    > hi Phil,
    > you can try to do it exclusively in clientside js, this way you wont need
    > to postback un-necessarily.
    > In the following code i pasted below, replace 'TextBox1' with the id of
    > your textbox.
    > Regards,
    > Alessandro Zifiglio
    > http://www.AsyncUI.net
    >
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > if (!this.IsPostBack)
    > {
    > this.DropDownList1.Attributes.Add("onchange",
    > "document.getElementById('TextBox1').value =
    > this.options[this.selectedIndex].value;");
    > }
    > }
    >
    >
    > "Phil Barber" <> ha scritto nel messaggio
    > news:...
    >>I have dropdown list I want to let the user pick an item in the list and
    >>add it to text box.
    >> It works all fine as long as I set the Autopostback on the dropdown list.
    >> the only problems I have is the speed of page as it is being redrawn on
    >> every selection.
    >> my question is there a way to move the selection to the text box on the
    >> client side without the trip to the server?
    >>
    >> this is the code behind the dropdiwn list:
    >> protected void CmbClaimPrefix_SelectedIndexChanged(object
    >> sender,EventArgs e)
    >>
    >> {
    >>
    >>
    >> if (TxtCvgNum.Text=="ALL")
    >>
    >> TxtCvgNum.Text=CmbCvgNum.SelectedValue;
    >>
    >> else
    >>
    >> TxtCvgNum.Text+=","+CmbCvgNum.SelectedValue;
    >>
    >> }
    >>
    >>

    >
    >
     
    Phil Barber, Jul 18, 2006
    #3
  4. hi phil, this test seems to work well. In page_load and button click event,
    i get the value supplied by the dropdownlist, so i dont know what you did to
    make it not work for you :

    Regards,
    Alessandro Zifiglio
    http://www.AsyncUI.net


    code behind :
    ------------------------
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!this.IsPostBack)
    {
    this.DropDownList1.Attributes.Add("onchange",
    "document.getElementById('TextBox1').value =
    this.options[this.selectedIndex].value;");
    }
    else
    {
    Response.Write("<br /> page_load fired, value of textbox is : "
    + TextBox1.Text);
    }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
    Response.Write("<br /> button click fired, value of textbox is : " +
    TextBox1.Text);
    }

    Declarative code :
    ------------------------


    <form id="form1" runat="server">
    <div>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:DropDownList ID="DropDownList1" runat="server">
    <asp:ListItem>a</asp:ListItem>
    <asp:ListItem>b</asp:ListItem>
    <asp:ListItem>c</asp:ListItem>
    <asp:ListItem>d</asp:ListItem>
    </asp:DropDownList>
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
    Text="Button" /></div>
    </form>

    "Phil Barber" <> ha scritto nel messaggio
    news:...
    > first I would like to say thanks that does work. I do still have one
    > problem
    > when I examine the text box in code the values that were added by the
    > dropdown list are not in the text property of the text box, even though
    > they show on the screen just fine!
    >
    > any ideas
    > thanks
    > phil
    >
    > "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote in
    > message news:e%...
    >> hi Phil,
    >> you can try to do it exclusively in clientside js, this way you wont need
    >> to postback un-necessarily.
    >> In the following code i pasted below, replace 'TextBox1' with the id of
    >> your textbox.
    >> Regards,
    >> Alessandro Zifiglio
    >> http://www.AsyncUI.net
    >>
    >> protected void Page_Load(object sender, EventArgs e)
    >> {
    >> if (!this.IsPostBack)
    >> {
    >> this.DropDownList1.Attributes.Add("onchange",
    >> "document.getElementById('TextBox1').value =
    >> this.options[this.selectedIndex].value;");
    >> }
    >> }
    >>
    >>
    >> "Phil Barber" <> ha scritto nel messaggio
    >> news:...
    >>>I have dropdown list I want to let the user pick an item in the list and
    >>>add it to text box.
    >>> It works all fine as long as I set the Autopostback on the dropdown
    >>> list.
    >>> the only problems I have is the speed of page as it is being redrawn on
    >>> every selection.
    >>> my question is there a way to move the selection to the text box on the
    >>> client side without the trip to the server?
    >>>
    >>> this is the code behind the dropdiwn list:
    >>> protected void CmbClaimPrefix_SelectedIndexChanged(object
    >>> sender,EventArgs e)
    >>>
    >>> {
    >>>
    >>>
    >>> if (TxtCvgNum.Text=="ALL")
    >>>
    >>> TxtCvgNum.Text=CmbCvgNum.SelectedValue;
    >>>
    >>> else
    >>>
    >>> TxtCvgNum.Text+=","+CmbCvgNum.SelectedValue;
    >>>
    >>> }
    >>>
    >>>

    >>
    >>

    >
    >
     
    Alessandro Zifiglio, Jul 18, 2006
    #4
  5. Phil Barber

    Phil Barber Guest

    I got it, i was using a textbox VS2005 control when I wsitch to the HTML
    input control it all worked ok.
    thanks again
    phil

    "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote in
    message news:e923K$...
    > hi phil, this test seems to work well. In page_load and button click
    > event, i get the value supplied by the dropdownlist, so i dont know what
    > you did to make it not work for you :
    >
    > Regards,
    > Alessandro Zifiglio
    > http://www.AsyncUI.net
    >
    >
    > code behind :
    > ------------------------
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > if (!this.IsPostBack)
    > {
    > this.DropDownList1.Attributes.Add("onchange",
    > "document.getElementById('TextBox1').value =
    > this.options[this.selectedIndex].value;");
    > }
    > else
    > {
    > Response.Write("<br /> page_load fired, value of textbox is : "
    > + TextBox1.Text);
    > }
    > }
    >
    > protected void Button1_Click(object sender, EventArgs e)
    > {
    > Response.Write("<br /> button click fired, value of textbox is : "
    > + TextBox1.Text);
    > }
    >
    > Declarative code :
    > ------------------------
    >
    >
    > <form id="form1" runat="server">
    > <div>
    > <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    > <asp:DropDownList ID="DropDownList1" runat="server">
    > <asp:ListItem>a</asp:ListItem>
    > <asp:ListItem>b</asp:ListItem>
    > <asp:ListItem>c</asp:ListItem>
    > <asp:ListItem>d</asp:ListItem>
    > </asp:DropDownList>
    > <asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
    > Text="Button" /></div>
    > </form>
    >
    > "Phil Barber" <> ha scritto nel messaggio
    > news:...
    >> first I would like to say thanks that does work. I do still have one
    >> problem
    >> when I examine the text box in code the values that were added by the
    >> dropdown list are not in the text property of the text box, even though
    >> they show on the screen just fine!
    >>
    >> any ideas
    >> thanks
    >> phil
    >>
    >> "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote
    >> in message news:e%...
    >>> hi Phil,
    >>> you can try to do it exclusively in clientside js, this way you wont
    >>> need to postback un-necessarily.
    >>> In the following code i pasted below, replace 'TextBox1' with the id of
    >>> your textbox.
    >>> Regards,
    >>> Alessandro Zifiglio
    >>> http://www.AsyncUI.net
    >>>
    >>> protected void Page_Load(object sender, EventArgs e)
    >>> {
    >>> if (!this.IsPostBack)
    >>> {
    >>> this.DropDownList1.Attributes.Add("onchange",
    >>> "document.getElementById('TextBox1').value =
    >>> this.options[this.selectedIndex].value;");
    >>> }
    >>> }
    >>>
    >>>
    >>> "Phil Barber" <> ha scritto nel messaggio
    >>> news:...
    >>>>I have dropdown list I want to let the user pick an item in the list and
    >>>>add it to text box.
    >>>> It works all fine as long as I set the Autopostback on the dropdown
    >>>> list.
    >>>> the only problems I have is the speed of page as it is being redrawn on
    >>>> every selection.
    >>>> my question is there a way to move the selection to the text box on the
    >>>> client side without the trip to the server?
    >>>>
    >>>> this is the code behind the dropdiwn list:
    >>>> protected void CmbClaimPrefix_SelectedIndexChanged(object
    >>>> sender,EventArgs e)
    >>>>
    >>>> {
    >>>>
    >>>>
    >>>> if (TxtCvgNum.Text=="ALL")
    >>>>
    >>>> TxtCvgNum.Text=CmbCvgNum.SelectedValue;
    >>>>
    >>>> else
    >>>>
    >>>> TxtCvgNum.Text+=","+CmbCvgNum.SelectedValue;
    >>>>
    >>>> }
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    Phil Barber, Jul 18, 2006
    #5
  6. you are welcome phil. By the way, you mean the opposite. Because it works
    for me on an asp.net textbox control :)

    Regards,
    Alessandro Zifiglio
    http://www.AsyncUI.net


    "Phil Barber" <> ha scritto nel messaggio
    news:...
    >I got it, i was using a textbox VS2005 control when I wsitch to the HTML
    >input control it all worked ok.
    > thanks again
    > phil
    >
    > "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote in
    > message news:e923K$...
    >> hi phil, this test seems to work well. In page_load and button click
    >> event, i get the value supplied by the dropdownlist, so i dont know what
    >> you did to make it not work for you :
    >>
    >> Regards,
    >> Alessandro Zifiglio
    >> http://www.AsyncUI.net
    >>
    >>
    >> code behind :
    >> ------------------------
    >> protected void Page_Load(object sender, EventArgs e)
    >> {
    >> if (!this.IsPostBack)
    >> {
    >> this.DropDownList1.Attributes.Add("onchange",
    >> "document.getElementById('TextBox1').value =
    >> this.options[this.selectedIndex].value;");
    >> }
    >> else
    >> {
    >> Response.Write("<br /> page_load fired, value of textbox is :
    >> " + TextBox1.Text);
    >> }
    >> }
    >>
    >> protected void Button1_Click(object sender, EventArgs e)
    >> {
    >> Response.Write("<br /> button click fired, value of textbox is : "
    >> + TextBox1.Text);
    >> }
    >>
    >> Declarative code :
    >> ------------------------
    >>
    >>
    >> <form id="form1" runat="server">
    >> <div>
    >> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    >> <asp:DropDownList ID="DropDownList1" runat="server">
    >> <asp:ListItem>a</asp:ListItem>
    >> <asp:ListItem>b</asp:ListItem>
    >> <asp:ListItem>c</asp:ListItem>
    >> <asp:ListItem>d</asp:ListItem>
    >> </asp:DropDownList>
    >> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
    >> Text="Button" /></div>
    >> </form>
    >>
    >> "Phil Barber" <> ha scritto nel messaggio
    >> news:...
    >>> first I would like to say thanks that does work. I do still have one
    >>> problem
    >>> when I examine the text box in code the values that were added by the
    >>> dropdown list are not in the text property of the text box, even though
    >>> they show on the screen just fine!
    >>>
    >>> any ideas
    >>> thanks
    >>> phil
    >>>
    >>> "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote
    >>> in message news:e%...
    >>>> hi Phil,
    >>>> you can try to do it exclusively in clientside js, this way you wont
    >>>> need to postback un-necessarily.
    >>>> In the following code i pasted below, replace 'TextBox1' with the id of
    >>>> your textbox.
    >>>> Regards,
    >>>> Alessandro Zifiglio
    >>>> http://www.AsyncUI.net
    >>>>
    >>>> protected void Page_Load(object sender, EventArgs e)
    >>>> {
    >>>> if (!this.IsPostBack)
    >>>> {
    >>>> this.DropDownList1.Attributes.Add("onchange",
    >>>> "document.getElementById('TextBox1').value =
    >>>> this.options[this.selectedIndex].value;");
    >>>> }
    >>>> }
    >>>>
    >>>>
    >>>> "Phil Barber" <> ha scritto nel messaggio
    >>>> news:...
    >>>>>I have dropdown list I want to let the user pick an item in the list
    >>>>>and add it to text box.
    >>>>> It works all fine as long as I set the Autopostback on the dropdown
    >>>>> list.
    >>>>> the only problems I have is the speed of page as it is being redrawn
    >>>>> on every selection.
    >>>>> my question is there a way to move the selection to the text box on
    >>>>> the client side without the trip to the server?
    >>>>>
    >>>>> this is the code behind the dropdiwn list:
    >>>>> protected void CmbClaimPrefix_SelectedIndexChanged(object
    >>>>> sender,EventArgs e)
    >>>>>
    >>>>> {
    >>>>>
    >>>>>
    >>>>> if (TxtCvgNum.Text=="ALL")
    >>>>>
    >>>>> TxtCvgNum.Text=CmbCvgNum.SelectedValue;
    >>>>>
    >>>>> else
    >>>>>
    >>>>> TxtCvgNum.Text+=","+CmbCvgNum.SelectedValue;
    >>>>>
    >>>>> }
    >>>>>
    >>>>>
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    Alessandro Zifiglio, Jul 19, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Prodip Saha
    Replies:
    4
    Views:
    2,615
    Peter Blum
    Mar 3, 2004
  2. Julia
    Replies:
    3
    Views:
    382
    Eliyahu Goldin
    Jun 22, 2005
  3. =?Utf-8?B?QW5hbmQ=?=
    Replies:
    2
    Views:
    2,737
    =?Utf-8?B?QW5hbmQ=?=
    Jan 11, 2006
  4. Jim M
    Replies:
    0
    Views:
    167
    Jim M
    Jan 14, 2004
  5. bill
    Replies:
    0
    Views:
    150
Loading...

Share This Page