|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
passing data on the cleint sideit 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; } 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;"); } } Show quoteHide quote "Phil Barber" <pbarb***@houston.rr.com> ha scritto nel messaggio news:uBwa5fnqGHA.4760@TK2MSFTNGP05.phx.gbl... >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; > > } > > 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 Show quoteHide quote "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote in message news:e%230hI0nqGHA.4992@TK2MSFTNGP05.phx.gbl... > 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" <pbarb***@houston.rr.com> ha scritto nel messaggio > news:uBwa5fnqGHA.4760@TK2MSFTNGP05.phx.gbl... >>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; >> >> } >> >> > > 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> Show quoteHide quote "Phil Barber" <pbarb***@houston.rr.com> ha scritto nel messaggio news:ezE3pWoqGHA.2256@TK2MSFTNGP03.phx.gbl... > 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%230hI0nqGHA.4992@TK2MSFTNGP05.phx.gbl... >> 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" <pbarb***@houston.rr.com> ha scritto nel messaggio >> news:uBwa5fnqGHA.4760@TK2MSFTNGP05.phx.gbl... >>>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; >>> >>> } >>> >>> >> >> > > 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 Show quoteHide quote "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote in message news:e923K$qqGHA.148@TK2MSFTNGP04.phx.gbl... > 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" <pbarb***@houston.rr.com> ha scritto nel messaggio > news:ezE3pWoqGHA.2256@TK2MSFTNGP03.phx.gbl... >> 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%230hI0nqGHA.4992@TK2MSFTNGP05.phx.gbl... >>> 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" <pbarb***@houston.rr.com> ha scritto nel messaggio >>> news:uBwa5fnqGHA.4760@TK2MSFTNGP05.phx.gbl... >>>>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; >>>> >>>> } >>>> >>>> >>> >>> >> >> > > 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 Show quoteHide quote "Phil Barber" <pbarb***@houston.rr.com> ha scritto nel messaggio news:esRt0QrqGHA.4996@TK2MSFTNGP04.phx.gbl... >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$qqGHA.148@TK2MSFTNGP04.phx.gbl... >> 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" <pbarb***@houston.rr.com> ha scritto nel messaggio >> news:ezE3pWoqGHA.2256@TK2MSFTNGP03.phx.gbl... >>> 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%230hI0nqGHA.4992@TK2MSFTNGP05.phx.gbl... >>>> 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" <pbarb***@houston.rr.com> ha scritto nel messaggio >>>> news:uBwa5fnqGHA.4760@TK2MSFTNGP05.phx.gbl... >>>>>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; >>>>> >>>>> } >>>>> >>>>> >>>> >>>> >>> >>> >> >> > >
onTextChanged won't fire in UserControl
How to have either/or steps in a wizard GridView, ObjectDataSource, Update problems. Add a control to a treenode. TreeView Windows control in .ASPX page Newbie: Calendar question? .Net 2.0 - WebBrowser control embedded in IE causes problems Commenting Out Controls In HTML View Autopostback and submit button Client-side web control/.NET based Java applets possible? |
|||||||||||||||||||||||