Sunday, March 11, 2012

Passing Data from one tab to another tab

i will give the code in C#.

suppose u r storing name of a person from a TextBox1 in one tab:

Session.Add("name", TextBox1.Text);

when u need to get the value to TextBox2 in another tab:

TextBox2.Text = Session["name"].ToString();

notice the square brackets when u have to read values from Session object

use this bit of code in the tab selection code .

"name" can be anything, think of it as a variable name but in quotes.

i hope this helps

cherio...



rdcrumbaker:

I am needing to pass information from data entered in a Textbox to another tab Textbox when the user changes tabs.

I have the Textbox on change writting to session.item, but I can't the textbox on the next tab to get this data.

Anyone have any sample code?

Why do u not set the other textbox in the change handler for the textbox, like u write to session.item?

If you provide us with your code, it will be an easy task to get you in the right direction.


Public

Sub TxtCompName_TextChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles txtCompName.TextChanged

Session.Item(

"ComputerName") = txtCompName.Text

That is what I have on the first tab, when the textbox is changed. But I can't get that value in the checkbox on the other tab. I tried putting code in the page load, but that didn't work.


Thank you for the replies. I will try these suggestions and post my results.


Hi There,

Since theer is no post back flicking between Tabs you have to do this with JavaScript. Do something like this.

<

Ajax:TabContainerID="TabContainer"runat="server"OnClientActiveTabChanged="ActiveTabChanged"><scripttype="text/javascript">function ActiveTabChanged(sender, e) {

TextBoxInTab2.value = TextBoxInTab1.value ;

}

</script>

Hope this works for you!

No comments:

Post a Comment