jaws1021
asked on
respond.redirect
This is correct code for what I need for different requirements, that panel 1 shows at the beginning, but now for the save button
clicked when I am on panel 2 and button2 also, after my below response .redirect, I need to be come back to panel2 and button2, this code brings button1 and panel1 which is correct for different times.
Do I need to add something to respond.redirect or ??
<input type="button" id="B1" style="background-color:li ghtgrey;" value="Claim" onclick='ButtonChange("B1" ,"lightgre y","Panel1 ");' />
... have two more button just like that..
<script language="JavaScript">
function ButtonChange(sender,color, id) {
document.getElementById(fi ndByPartOf ID("Panel1 ", 'DIV')).style.visibility = "hidden";
document.getElementById(fi ndByPartOf ID("Panel1 ", 'DIV')).style.position = "absolute";
document.getElementById(fi ndByPartOf ID("Panel2 ", 'DIV')).style.visibility = "hidden";
document.getElementById(fi ndByPartOf ID("Panel2 ", 'DIV')).style.position = "absolute";
document.getElementById(fi ndByPartOf ID("Panel3 ", 'DIV')).style.visibility = "hidden";
document.getElementById(fi ndByPartOf ID("Panel3 ", 'DIV')).style.position = "absolute";
document.getElementById(fi ndByPartOf ID(id, 'DIV')).style.visibility = "";
document.getElementById(fi ndByPartOf ID(id, 'DIV')).style.position = "";
// set button color here
document.getElementById(fi ndByPartOf ID("B1", 'INPUT')).style.background Color = "";
document.getElementById(fi ndByPartOf ID("B2", 'INPUT')).style.background Color = "";
document.getElementById(fi ndByPartOf ID("B3", 'INPUT')).style.background Color = "";
document.getElementById(se nder).styl e.backgrou ndColor = color;
}
<asp:Panel ID="Panel1" style="" runat="server">
<asp:Panel ID="Panel2" style="visibility:hidden;p osition:ab solute;" runat="server">
<asp:Panel ID="Panel3" style="visibility:hidden;p osition:ab solute;" runat="server">
Response.Redirect("mypage. aspx?id=" & CInt(Request.QueryString(" iclaimid") ) & "&Type=" & Request.QueryString("type" ))
clicked when I am on panel 2 and button2 also, after my below response .redirect, I need to be come back to panel2 and button2, this code brings button1 and panel1 which is correct for different times.
Do I need to add something to respond.redirect or ??
<input type="button" id="B1" style="background-color:li
... have two more button just like that..
<script language="JavaScript">
function ButtonChange(sender,color,
document.getElementById(fi
document.getElementById(fi
document.getElementById(fi
document.getElementById(fi
document.getElementById(fi
document.getElementById(fi
document.getElementById(fi
document.getElementById(fi
// set button color here
document.getElementById(fi
document.getElementById(fi
document.getElementById(fi
document.getElementById(se
}
<asp:Panel ID="Panel1" style="" runat="server">
<asp:Panel ID="Panel2" style="visibility:hidden;p
<asp:Panel ID="Panel3" style="visibility:hidden;p
Response.Redirect("mypage.
ASKER
with this code right now, when I respond.redirect basically refreshing my page, I am seeing button1's panel which is panel1. I want to see panel2 and button2.
<input type="button" id="B2" value="Selection" onclick='ButtonChange("B2" ,"#ffcc99" ,"Panel2") ;' />
<input type="button" id="B2" value="Selection" onclick='ButtonChange("B2"
Ah, I understand. You are setting the visibility with JavaScript, but on PostBack it is not being retained? You'll need to use AJAX and Client Callbacks for that:
http://msdn.microsoft.com/msdnmag/issues/04/08/cuttingedge/
http://www.codeproject.com/aspnet/ClientCallBackAspNet2.asp
http://www.dotnetjunkies.com/Article/E80EC96F-1C32-4855-85AE-9E30EECF13D7.dcik
Using Client Callbacks will enable sharing client-side state changes with the server.
-dZ.
http://msdn.microsoft.com/msdnmag/issues/04/08/cuttingedge/
http://www.codeproject.com/aspnet/ClientCallBackAspNet2.asp
http://www.dotnetjunkies.com/Article/E80EC96F-1C32-4855-85AE-9E30EECF13D7.dcik
Using Client Callbacks will enable sharing client-side state changes with the server.
-dZ.
ASKER
I have ajax update panel for my grid, but buttons and save button is not include do you think I should include that?
If you change the visibility of the controls in the client side using javascript, you need to use Client Callback to make the server aware of the change. Otherwise, when you postback, the server will put the visibility back to the way it was (since it doesn't know of the change on the client).
Does this explain it better?
-dZ.
Does this explain it better?
-dZ.
ASKER
I have never done callback, I looked at the link it explains high level, recommending blog page is down, I need this asap, can you help me how to set up that?
ASKER
this above code actually working fine for different requirements, but when I am on button2 (it is like tab2) my panel2 shows and it is fine, but after postback, it is going to button1, instead I want this to go button2.
I'm sorry, I understand exactly what your problem is, and it does require a callback. However, I too have never used them, plus I do not have access to .NET 2.0 to test any of the code. I will read the tutorials and see if I can post some working code for you. I think at this time your best bet is to study the information in the MSDN Cutting Edge blog, which seems to be very thorough:
http://msdn.microsoft.com/msdnmag/issues/04/08/cuttingedge/#S2
-dZ.
http://msdn.microsoft.com/msdnmag/issues/04/08/cuttingedge/#S2
-dZ.
ASKER
Thank You so much!
Put a hidden field the page. In the ButtonChange() javascript function, set the value of this hidden field to the id of the button that was just pressed. Then check the hidden field value in both client-side and server-side code to determine which button was pressed last.
would this work do you think?
Put a hidden field the page. In the ButtonChange() javascript function, set the value of this hidden field to the id of the button that was just pressed. Then check the hidden field value in both client-side and server-side code to determine which button was pressed last.
would this work do you think?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<input type="hidden" name="__TABSTATE" id="__TABSTATE" />). When a tab is clicked, use JavaScript to add the ID to this field, like this:
var txtState = document.getElementById("_ _TABSTATE" );
txtState.value = <id of current tab>;
but I have click event already and holds the buttonchange function, should I add this to it?
If Page.IsPostBack Then
'Dim key As String = Request.Form("__TABSTATE")
'Page.ClientScript.Registe rStartupSc ript(Me.Ge tType(), "restoreTab", String.Format("switchTab(' {0}');", key), True)
Where "switchTab" is the JavaScript function that pass the Panel ID into to switch the visible tabs.
I am confused between switch tab and restoretab because I already have function above buttonchange()
var txtState = document.getElementById("_
txtState.value = <id of current tab>;
but I have click event already and holds the buttonchange function, should I add this to it?
If Page.IsPostBack Then
'Dim key As String = Request.Form("__TABSTATE")
'Page.ClientScript.Registe
Where "switchTab" is the JavaScript function that pass the Panel ID into to switch the visible tabs.
I am confused between switch tab and restoretab because I already have function above buttonchange()
Ah, I see, you are always setting the visibility on the client-side. You can put that code in the OnPreRender() method instead of the OnClick event.
Can you post the code to switchTab and restoreTab functions?
-dZ.
Can you post the code to switchTab and restoreTab functions?
-dZ.
-dZ.