473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Ajax Tab Container issue

Ok so I am using the ajax control toolkit tabcontainer with 5 tab panels inside of it. Each tab contains areas where one must input information. The page also contains add, edit, and delete buttons with gridviews above them.

What I am trying to do is to make the user save or cancel changes when they change the activetab. I am using a javascript confirm box but I need to try to retrieve the value of what is pressed from the javascript box to decide whether to discard the changes or stay on the page and make the user finish the input. Is there any way to save the value from the javascript box into a variable so or must i try something else?

If you need any further explanation i will be more than glad to respond.

PS I wasnt sure whether to post this in the javascript section or the asp.net section since im using asp.net with c#.

This is kinda what im using but would like to turn it into a confirm box and pull the true or false value.

Expand|Select|Wrap|Line Numbers
  1. protected void TabContainerContent_ActiveTabChanged(object sender, EventArgs e)
  2.     {
  3.  
  4.         if (TabContainerContent.ActiveTabIndex != 0)
  5.         {
  6.             btnDelete.Visible = false;
  7.             btnDeleteOthers.Visible = true;
  8.         }
  9.         else
  10.         {
  11.             btnDelete.Visible = true;
  12.             btnDeleteOthers.Visible = false;
  13.         }
  14.  
  15.         btnDeleteOthers.Enabled = false;
  16.  
  17.         //check to make sure user has saved tab before moving on
  18.          if (Convert.ToString(Session["buttonpressed"]) == "Add" || Convert.ToString(Session["buttonpressed"]) == "Edit" && Convert.ToString(Session["savepressed"]) == "No")
  19.          {
  20.  
  21.              string tmp = "";
  22.              tmp = "<script language='javascript'>";
  23.              tmp += "alert('You must save or cancel to continue');";
  24.              tmp += "</script>";
  25.              Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", tmp);
  26. }
  27.          Session["savepressed"] = "No";
  28.  
  29.  
  30.  
  31.     }
  32.  
May 17 '10 #1

✓ answered by Frinavale

Ok I tried it with the Tab Control and it still works fine for me.
Check out what I have:

(ASPX code markup)
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>
  2.  
  3. <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head runat="server">
  7.     <title>Test</title>
  8. </head>
  9.  <body>
  10.   <form id="form1" runat="server">
  11.     <asp:ScriptManager ID="smanager" runat="server"> </asp:ScriptManager>
  12.     <asp:UpdatePanel ID="SectionUpdate" runat="server">
  13.         <ContentTemplate>
  14.             <cc1:TabContainer ID="TabContainerContent" runat="server" ActiveTabIndex="4" Height="500px"
  15.                 BackColor="White" OnActiveTabChanged="TabContainerContent_ActiveTabChanged" AutoPostBack="True"
  16.                 OnClientActiveTabChanged="show_confirm">
  17.                 <cc1:TabPanel ID="tab1" runat="server">
  18.                     <HeaderTemplate>
  19.                         Tab 1
  20.                     </HeaderTemplate>
  21.                     <ContentTemplate>
  22.                         Content for tab 1
  23.                     </ContentTemplate>
  24.                 </cc1:TabPanel>
  25.                 <cc1:TabPanel ID="tab2" runat="server">
  26.                     <HeaderTemplate>
  27.                         Tab 2
  28.                     </HeaderTemplate>
  29.                     <ContentTemplate>
  30.                         Content for tab 2
  31.                     </ContentTemplate>
  32.                 </cc1:TabPanel>
  33.                 <cc1:TabPanel ID="tab3" runat="server">
  34.                     <HeaderTemplate>
  35.                         Tab 3
  36.                     </HeaderTemplate>
  37.                     <ContentTemplate>
  38.                         Content for tab 3
  39.                     </ContentTemplate>
  40.                 </cc1:TabPanel>
  41.                 <cc1:TabPanel ID="tab4" runat="server">
  42.                     <HeaderTemplate>
  43.                         Tab 4
  44.                     </HeaderTemplate>
  45.                     <ContentTemplate>
  46.                         Content for tab 4
  47.                     </ContentTemplate>
  48.                 </cc1:TabPanel>
  49.                 <cc1:TabPanel ID="tab5" runat="server">
  50.                     <HeaderTemplate>
  51.                         Tab 5
  52.                     </HeaderTemplate>
  53.                     <ContentTemplate>
  54.                         Content for tab 5
  55.                     </ContentTemplate>
  56.                 </cc1:TabPanel>
  57.             </cc1:TabContainer>
  58.             <br />
  59.             <asp:Label ID="UserSelectionResult" runat="server"></asp:Label>
  60.             <asp:HiddenField ID="theHiddenField" runat="server" Value="nothing set" />
  61.  
  62.             <script type="text/javascript">
  63.                 function show_confirm() {
  64.                     var r = confirm("Press a button");
  65.                     //get the hidden field reference:
  66.                     var userSelectedYesElement = document.getElementById("<%=theHiddenField.ClientID%>");
  67.                     if (userSelectedYesElement) {
  68.                         //if the userSelectedYesElement exists, set it's value
  69.                         //to the user's selection
  70.                         userSelectedYesElement.value = r;
  71.                     }
  72.  
  73.                     //returning what the user selected (because that is what you were doing)
  74.                     return r;
  75.                 }
  76.             </script>
  77.         </ContentTemplate>
  78.     </asp:UpdatePanel>
  79.   </form>
  80.  </body>
  81. </html>
(C# code)
Expand|Select|Wrap|Line Numbers
  1. protected void TabContainerContent_ActiveTabChanged(object sender, EventArgs e){
  2.   UserSelectionResult.Text = "You selected: " + theHiddenField.Value;    
  3. }
-Frinny

16 11981
Frinavale
9,735 Expert Mod 8TB
Use a JavaScript confirm instead of a JavaScript alert :)
May 17 '10 #2
yes i do use a javascript confirm but not in that code. i change it a confirm but im trying to save the confirm value to a variable in asp. If the user selects ok to save the work...i want to save the changes to the database. if they select cancel i want to discard the changes and allow them to move to another tab. my main problem is that i cant capture the value of the javascript confirmbox.

this is the javascript function in my html page:
Expand|Select|Wrap|Line Numbers
  1. function show_confirm()
  2.         {
  3.  
  4.             var r=confirm("Press a button");
  5.  
  6.                 if (r==true)
  7.                 {
  8.                   //return the value               
  9.                 }
  10.             else
  11.                 {
  12.                    //return the value 
  13.                 }
  14.         }
  15.  
this is the code in my .cs page
Expand|Select|Wrap|Line Numbers
  1. protected void TabContainerContent_ActiveTabChanged(object sender, EventArgs e)
  2.     {
  3.  
  4.         if (TabContainerContent.ActiveTabIndex != 0)
  5.         {
  6.             btnDelete.Visible = false;
  7.             btnDeleteOthers.Visible = true;
  8.         }
  9.         else
  10.         {
  11.             btnDelete.Visible = true;
  12.             btnDeleteOthers.Visible = false;
  13.         }
  14.  
  15.         btnDeleteOthers.Enabled = false;
  16.  
  17.         //check to make sure user has saved tab before moving on
  18.          if (Convert.ToString(Session["buttonpressed"]) == "Add" || Convert.ToString(Session["buttonpressed"]) == "Edit" && Convert.ToString(Session["savepressed"]) == "No")
  19.          {
  20.  
  21.              string tmp = "";
  22.              tmp = "<script language='javascript'>";
  23.              tmp += "show_confirm();";
  24.              tmp += "</script>";
  25.              Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", tmp);
  26.              TabContainerContent.ActiveTabIndex = Convert.ToInt32(Session["activetab"]);
  27.  
  28.  
  29.  
  30.          }
  31.          Session["savepressed"] = "No";
  32.  
  33.  
  34.  
  35.     }
  36.  
the reason i want to save this value is because im not using a on_click button event. I'm firing this jscript when the active tab is changed.
May 17 '10 #3
Frinavale
9,735 Expert Mod 8TB
Use a HiddenField to store the value that the user selected.
HiddenFields are accessible in JavaScript and in your C# code (use an ASP.NET HiddenField to make life easier).

Add an ASP.NET HiddenField to the page and give it an ID like "userSelectedYes" (or something that makes sense to you).

Then modify your JavaScript to retrieve this element and set the value when the user clicks yes or no. Then when the page submits the user's choice will be accessible in the userSelectedYes.Value.

JS:
Expand|Select|Wrap|Line Numbers
  1. function show_confirm(){
  2.    var r=confirm("Press a button");
  3.    //get the hidden field reference:
  4.   var userSelectedYesElement = document.getElementById("<%=userSelectedYes.ClientID%>");
  5.   if(userSelectedYesElement){
  6.     //if the userSelectedYesElement exists, set it's value
  7.     //to the user's selection
  8.     userSelectedYesElement.value = r;
  9.   }
  10.  
  11.   //returning what the user selected (because that is what you were doing)
  12.   return r;
  13. }
Please note my use of the ASP classic syntax <%= %>. That will print the value of the userSelectedYes HiddenField's ClientID into the page at that place. If you are dynamically generating this code in your C# code then you'll have the following code (which amounts to the same thing):

C# (generating JS)
Expand|Select|Wrap|Line Numbers
  1. StringBuilder script = New StringBuilder();
  2. script.Append("function show_confirm(){ \n");
  3. script.Append("  var r=confirm(\"Press a button\"); \n");
  4. script.Append("   //get the hidden field reference: \n");
  5. script.Append("  var userSelectedYesElement = document.getElementById("script.Append(\"");
  6. script.Append(userSelectedYes.ClientID);
  7. script.Append( "\"); \n");
  8. script.Append("  if(userSelectedYesElement){ \n");
  9. script.Append("    //if the userSelectedYesElement exists, set it's value \n");
  10. script.Append("    //to the user's selection \n");
  11. script.Append("    userSelectedYesElement.value = r; \n");
  12. script.Append("  } \n");
  13. script.Append(" \n");
  14. script.Append("  //returning what the user selected (because that is what you were doing) \n");
  15. script.Append("  return r; \n");
  16. script.Append("} \n");
Now, in your Button Click event (or whatever) you can check what the user selected:

C# (Button Click Event handling method or whatever)
Expand|Select|Wrap|Line Numbers
  1.   Boolean userSelection = (Boolean) userSelectedYes.Value;
  2.  
-Frinny
May 17 '10 #4
With this
Expand|Select|Wrap|Line Numbers
  1. protected void TabContainerContent_ActiveTabChanged(object sender, EventArgs e)
  2.     {
  3.  
  4.         if (TabContainerContent.ActiveTabIndex != 0)
  5.         {
  6.             btnDelete.Visible = false;
  7.             btnDeleteOthers.Visible = true;
  8.         }
  9.         else
  10.         {
  11.             btnDelete.Visible = true;
  12.             btnDeleteOthers.Visible = false;
  13.         }
  14.  
  15.         btnDeleteOthers.Enabled = false;
  16.  
  17.         //check to make sure user has saved tab before moving on
  18.          if (Convert.ToString(Session["buttonpressed"]) == "Add" || Convert.ToString(Session["buttonpressed"]) == "Edit" && Convert.ToString(Session["savepressed"]) == "No")
  19.          {
  20.  
  21.              string tmp = "";
  22.              tmp = "<script language='javascript'>";
  23.              tmp += "show_confirm();";
  24.              tmp += "</script>";
  25.              Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", tmp);
  26.              TabContainerContent.ActiveTabIndex = Convert.ToInt32(Session["activetab"]);
  27.              string userSelection = userSelectedYes.Value;
  28.              Label1.Text = userSelection; //just to post the value so i can see it
  29.  
  30.  
  31.          }
  32.          Session["savepressed"] = "No";
  33.  
  34.  
  35.  
  36.     }
  37.  
and this

Expand|Select|Wrap|Line Numbers
  1. function show_confirm(){
  2.        var r=confirm("Press a button");
  3.        //get the hidden field reference:
  4.       var userSelectedYesElement = document.getElementById("<%=userSelectedYes.ClientID%>");
  5.       if(userSelectedYesElement){
  6.         //if the userSelectedYesElement exists, set it's value
  7.         //to the user's selection
  8.         userSelectedYesElement.value = r;
  9.       }
  10.  
  11.      //returning what the user selected (because that is what you were doing)
  12.      return r;
  13.    }
  14.  
  15.  
I am getting this error
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
May 17 '10 #5
Frinavale
9,735 Expert Mod 8TB
Umm..never seen that error before.
Maybe it's because you're using C# and I didn't include a ";" at the end of the <%= %> statement.

Try changing it to:
Expand|Select|Wrap|Line Numbers
  1.       var userSelectedYesElement = document.getElementById("<%=userSelectedYes.ClientID;%>");
-Frinny
May 17 '10 #6
With the semicolon added it says:
Error 1 )
Error 2 Invalid expression term ')'
May 18 '10 #7
Frinavale
9,735 Expert Mod 8TB
So, maybe you don't need a ";" (??)

In your original error....I don't understand where or why your control collection is being modified.......

-Frinny
May 18 '10 #8
It says that whenever I put <%= %> on any of my controls and try to modify them. Ive tried to do this to various textboxes and such just to test and cant seem to get any of them to work. Ive also tried with single quotes no single quotes, ect, ect. Basically all i want to do is retrieve one of my controls and then put something in it from the javascript.
May 18 '10 #9
i just read something about this would work if i took it out of the <head> tag. ill let you know how it goes
May 18 '10 #10
Ok so it compiles and such but the result is not being stored to the control. I tried using textbox, label, and hiddenfield to save the result and its not working. I just made a simple javascript function to see if i can write to any control and I cant....i must not be doing it right or something. Checking my error console on firefox shows that the userSelectedYesElement is null....so somehow the getelementbyid is not working.
May 18 '10 #11
Frinavale
9,735 Expert Mod 8TB
I don't know why you're having a problem with this.
I use this technique all the time.

Mind you I'm not "modifying" controls.

Anyways, I just set up a test aspx page to try this out in C# (I mainly use VB.NET) and this is what I have (and it works fine).

ASPX code:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head runat="server">
  6.     <title>Test</title>
  7. </head>
  8. <body>
  9.   <form id="form1" runat="server">
  10.     <div>
  11.        <asp:Button ID="theButton" runat="server" OnClientClick="show_confirm();" OnClick="theButton_Click" Text="Click Me!" />
  12.         <br />
  13.         <asp:Label ID="UserSelectionResult" runat="server"></asp:Label>
  14.         <asp:HiddenField ID="theHiddenField" runat="server" Value="nothing set" />
  15.  
  16.         <script type="text/javascript">
  17.             function show_confirm() {
  18.                 var r = confirm("Press a button");
  19.                 //get the hidden field reference:
  20.                 var userSelectedYesElement = document.getElementById("<%=theHiddenField.ClientID%>");
  21.                 if (userSelectedYesElement) {
  22.                     //if the userSelectedYesElement exists, set it's value
  23.                     //to the user's selection
  24.                     userSelectedYesElement.value = r;
  25.                 }
  26.  
  27.                 //returning what the user selected (because that is what you were doing)
  28.                 return r;
  29.             }
  30.         </script>
  31.  
  32.     </div>
  33.  
  34.   </form>
  35. </body>
  36. </html>
  37.  
In my C# code for the button click event I am just showing whether or not the user chose true (ok) or false (cancel):
Expand|Select|Wrap|Line Numbers
  1. protected void theButton_Click(Object sender, EventArgs e) {
  2.   UserSelectionResult.Text ="You selected: " + theHiddenField.Value;  
  3. }
Like I said...it works fine.

-Frinny
May 18 '10 #12
I think its because im using the ajax toolkit. When i put the function just inside the body it actually runs but it cant find the hidden field. When i place it inside of the tabcontainer tag...the firefox error console says show_confirm is not defined. I think half the problem is that im calling the function inside of the tab_index changed event. Im not using button clicks. I know i ran into a problem before where i needed to put another hidden field im using in a certain place or it couldnt be accessed and Im pretty sure its because of the toolkit.
This is what i have in the tabcontainer active tab changed event. This toolkit has added some nice features for me to use but also has its pitfalls.
Expand|Select|Wrap|Line Numbers
  1. protected void TabContainerContent_ActiveTabChanged(object sender, EventArgs e)
  2.     {
  3.  
  4.         if (TabContainerContent.ActiveTabIndex != 0)
  5.         {
  6.             btnDelete.Visible = false;
  7.             btnDeleteOthers.Visible = true;
  8.         }
  9.         else
  10.         {
  11.             btnDelete.Visible = true;
  12.             btnDeleteOthers.Visible = false;
  13.         }
  14.  
  15.         btnDeleteOthers.Enabled = false;
  16.  
  17.         //check to make sure user has saved tab before moving on
  18.          if (Convert.ToString(Session["buttonpressed"]) == "Add" || Convert.ToString(Session["buttonpressed"]) == "Edit" && Convert.ToString(Session["savepressed"]) == "No")
  19.          {
  20.  
  21.              string tmp = "";
  22.              tmp = "<script language='javascript'> \n";
  23.              tmp += "show_confirm(); \n";
  24.              tmp += "</script>";
  25.              Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", tmp);
  26.              TabContainerContent.ActiveTabIndex = Convert.ToInt32(Session["activetab"]);
  27.             // string userSelection = userSelectedYes.Value;
  28.  
  29.  
  30.  
  31.          }
  32.          Session["savepressed"] = "No";
  33.  
  34.  
  35.  
  36.     }
  37.  
  38.  
This is what i have in my html
Expand|Select|Wrap|Line Numbers
  1. <cc1:TabContainer ID="TabContainerContent" runat="server" ActiveTabIndex="4" Height="500px" BackColor="White" OnActiveTabChanged = "TabContainerContent_ActiveTabChanged" AutoPostBack="True" >
  2.                     <script type="text/javascript">
  3.     function show_confirm()
  4.     {
  5.       var r=confirm("Press a button");
  6.        //get the hidden field reference:
  7.        document.writeln("i made it to the function");
  8.        var userSelectedYesElement = document.getElementById("<%=txttesting.ClientID%>");
  9.         userSelectedYesElement.value = "yes";
  10.       if(userSelectedYesElement)
  11.       {
  12.      //if the userSelectedYesElement exists, set it's value to the user's selection
  13.         userSelectedYesElement.value = r;
  14.       }
  15.  
  16.      //returning what the user selected (because that is what you were doing)
  17.      return r;
  18.    }
  19.  
  20.  
  21.     </script>
  22.  
I have everything setup almost word for word like you do except where im calling my function in the activetab event.
May 18 '10 #13
Frinavale
9,735 Expert Mod 8TB
Ok there are 2 things that you can do to get this script to work.

The first thing is to try and add it in side the update panel that is going to be used.

The second thing is to dynamically generate the script in your C# code and register it with the ScriptManager on the page.

UpdatePanels make things a little trickier.

Please note that you MUST put the hidden field in the UpdatePanel!
May 18 '10 #14
Frinavale
9,735 Expert Mod 8TB
Ok I tried it with the Tab Control and it still works fine for me.
Check out what I have:

(ASPX code markup)
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>
  2.  
  3. <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head runat="server">
  7.     <title>Test</title>
  8. </head>
  9.  <body>
  10.   <form id="form1" runat="server">
  11.     <asp:ScriptManager ID="smanager" runat="server"> </asp:ScriptManager>
  12.     <asp:UpdatePanel ID="SectionUpdate" runat="server">
  13.         <ContentTemplate>
  14.             <cc1:TabContainer ID="TabContainerContent" runat="server" ActiveTabIndex="4" Height="500px"
  15.                 BackColor="White" OnActiveTabChanged="TabContainerContent_ActiveTabChanged" AutoPostBack="True"
  16.                 OnClientActiveTabChanged="show_confirm">
  17.                 <cc1:TabPanel ID="tab1" runat="server">
  18.                     <HeaderTemplate>
  19.                         Tab 1
  20.                     </HeaderTemplate>
  21.                     <ContentTemplate>
  22.                         Content for tab 1
  23.                     </ContentTemplate>
  24.                 </cc1:TabPanel>
  25.                 <cc1:TabPanel ID="tab2" runat="server">
  26.                     <HeaderTemplate>
  27.                         Tab 2
  28.                     </HeaderTemplate>
  29.                     <ContentTemplate>
  30.                         Content for tab 2
  31.                     </ContentTemplate>
  32.                 </cc1:TabPanel>
  33.                 <cc1:TabPanel ID="tab3" runat="server">
  34.                     <HeaderTemplate>
  35.                         Tab 3
  36.                     </HeaderTemplate>
  37.                     <ContentTemplate>
  38.                         Content for tab 3
  39.                     </ContentTemplate>
  40.                 </cc1:TabPanel>
  41.                 <cc1:TabPanel ID="tab4" runat="server">
  42.                     <HeaderTemplate>
  43.                         Tab 4
  44.                     </HeaderTemplate>
  45.                     <ContentTemplate>
  46.                         Content for tab 4
  47.                     </ContentTemplate>
  48.                 </cc1:TabPanel>
  49.                 <cc1:TabPanel ID="tab5" runat="server">
  50.                     <HeaderTemplate>
  51.                         Tab 5
  52.                     </HeaderTemplate>
  53.                     <ContentTemplate>
  54.                         Content for tab 5
  55.                     </ContentTemplate>
  56.                 </cc1:TabPanel>
  57.             </cc1:TabContainer>
  58.             <br />
  59.             <asp:Label ID="UserSelectionResult" runat="server"></asp:Label>
  60.             <asp:HiddenField ID="theHiddenField" runat="server" Value="nothing set" />
  61.  
  62.             <script type="text/javascript">
  63.                 function show_confirm() {
  64.                     var r = confirm("Press a button");
  65.                     //get the hidden field reference:
  66.                     var userSelectedYesElement = document.getElementById("<%=theHiddenField.ClientID%>");
  67.                     if (userSelectedYesElement) {
  68.                         //if the userSelectedYesElement exists, set it's value
  69.                         //to the user's selection
  70.                         userSelectedYesElement.value = r;
  71.                     }
  72.  
  73.                     //returning what the user selected (because that is what you were doing)
  74.                     return r;
  75.                 }
  76.             </script>
  77.         </ContentTemplate>
  78.     </asp:UpdatePanel>
  79.   </form>
  80.  </body>
  81. </html>
(C# code)
Expand|Select|Wrap|Line Numbers
  1. protected void TabContainerContent_ActiveTabChanged(object sender, EventArgs e){
  2.   UserSelectionResult.Text = "You selected: " + theHiddenField.Value;    
  3. }
-Frinny
May 18 '10 #15
This worked for me now. The only problem is that I dont want the function to fire unless someone has hit the add or edit buttons. I have session variables saving which button has been pressed and only want this to run if someone actually has clicked them. Currently what we have here fires everytime a tab is changed regardless of if a button has been pressed. I do appreciate all the help though. You have helped me so much with all my questions so far.
May 19 '10 #16
Frinavale
9,735 Expert Mod 8TB
There are 2 aspects to the Tab control: client side (run via JavaScript) and side.

This is what happens....
  • The user selects a tab
  • The JavaScript responsible for switching tabs is executed
  • The JavaScript that displays the confirm is executed
  • The JavaScript responsible for causing a Postback to the server is executed
  • The page posts back to the server and your method that handles the tab index changed event is executed

Now, if you want the server side not to be executed you can wrap the contents of the server side Tab Index Changing event in an If block that checks if the user selected yes or no.

Something like:
Expand|Select|Wrap|Line Numbers
  1. protected void TabContainerContent_ActiveTabChanged(object sender, EventArgs e){
  2.  Boolean userSelectedYes;
  3.  Boolean.TryParse(theHiddenField.Value,userSelectedYes);    
  4.  
  5.   if(userSelectedYes){
  6.     //Functionality here....
  7.   }
  8. }
If you want the client side stuff to not be executed that could require some figuring out :)

-Frinny
May 19 '10 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: brendan.ganning | last post by:
I am working on converting an app to a CSS layout. I have run the CSS validation on it and the only errors that appear are ones that ColdFusion would have fixed. The issue there is a data table...
1
by: nx.nine | last post by:
hi, i've done some searching and haven't found a solution that worked, hopefully someone here can help. i apologize in advance for my dyslexic thought process. i have an xml file being...
0
by: =?Utf-8?B?bmt3?= | last post by:
1. Any shortcut if I put all controls in an Ajax container? 2. I have two ajax containers use a label for error message label, which had to put outside of the two containers or in a third...
2
by: defyinggravity | last post by:
Hi this is a newbie alert! This may seem really basic to most, but I am a total beginner, so please don't laugh, or gif me false info...lol I will use it. I have an ajax container loading on my...
1
by: conspireagainst | last post by:
Is there any possible way (I'm using prototype framework) to glean what the name of the container element to be updated (using Ajax.Updater) is? I have appended at the bottom of prototype.js a...
1
by: jrcapp | last post by:
Let's see if I can clearly explain what I am doing with AJAX. On my Web site, I have a TabContainer that has 2 TabPanels. Inside each Panel, I am dynamically (using a SQL query) creating an...
11
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have run into a situation that if a page/tab that uses the Ajax toolkit (using .net version 3.5) is closed before the Ajax enable controls complete loading, then IE locks up. Does it in both IE7...
8
by: puzzlecracker | last post by:
Guys, what is more preferable, given that I don't have access to boost or shared pointers: std::map<T*, std::set<T2** *_myMap; vs. std::map<T*, std::set<T2* *myMap; Notice that in the...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: tomNevs | last post by:
The code posted below is not working in IE. It finishes w/ a message in the browser "Done, but with errors" and the tabcontrol is not displayed. It works fine in Firefox. If you look at the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.