passing data on the cleint side

P

Phil Barber

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;

}
 
A

Alessandro Zifiglio

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;");
}
}
 
P

Phil Barber

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 said:
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 said:
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;

}
 
A

Alessandro Zifiglio

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 said:
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 said:
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 said:
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;

}
 
P

Phil Barber

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 said:
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 said:
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 said:
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" <[email protected]> ha scritto nel messaggio
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;

}
 
A

Alessandro Zifiglio

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 said:
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 said:
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 said:
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

in message 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" <[email protected]> ha scritto nel messaggio
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;

}
 

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

Forum statistics

Threads
474,102
Messages
2,570,645
Members
47,247
Latest member
GabrieleL2

Latest Threads

Top