i have a problem with aspx page that have some textbox and a checkbox .
i put code onCheckBox1_CheckedChangedthat value of first textbox put in second textbox.
if i edit the value of first textbox then value should be update of second textbox.
I cant post the page so want to fire click event. my code is
privatevoid CheckBox1_CheckedChanged(object sender, System.EventArgs e)
{
TextBox2.Text=TextBox1.Text;
}
But if you want the textbox to automatically change the value of the second textbox without the checkbox, then you need to look into some javascript.
Zath
yes autopostback is true.
And i don want to use javascript. plz give me the solution in asp.net or C#.
i donot know if what think is useful but you can try
have you tried to place the code in the textbox event with adding if statement for the checkbox and use auto post back ... and see if that will help??!!!
but i think the JS is better for a client side operations to reduce the traffic on the server !!! let me know what you do!!
What code do you have in your page_load event? Is there anything there that manipulates the text box? remeber that the page_load event fires every time the page posts back.
smtraber
i tried this code in the check box method
IfMe.CheckBox1.Checked =TrueThen
Me.TextBox2.Text =Me.TextBox1.Text
EndIf
and the auto post back is true for the check box
now when i write the text and tick after that i will get the change !!!
Is that what you meant?
Your code is ok and fine
IfMe.CheckBox1.Checked =TrueThen
Me.TextBox2.Text =Me.TextBox1.Text
EndIf
but the problem is that when i change the value of textbox1 (after check clicked )
then also value should be change without post the form.
Unfortunately, you won't be able to have this event fire without posting the form back to the server unless you use javascript. If your textboxes are set to autopostback=true, then the post back and therefore text_changed event should fire as soon as one of your textboxes loses focus.arvindharitus wrote: but the problem is that when i change the value of textbox1 (after check clicked )
then also value should be change without post the form.
smtraber
Check out what's the state of the "enableviewstate" property of the controls you are using? If that is false then just change them to true.
0 comments:
Post a Comment