Link to home
Start Free TrialLog in
Avatar of jaws1021
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:lightgrey;" value="Claim" onclick='ButtonChange("B1","lightgrey","Panel1");' />
... have two more button just like that..


<script language="JavaScript">
   function ButtonChange(sender,color,id) {

    document.getElementById(findByPartOfID("Panel1", 'DIV')).style.visibility = "hidden";
    document.getElementById(findByPartOfID("Panel1", 'DIV')).style.position = "absolute";
   
   
    document.getElementById(findByPartOfID("Panel2", 'DIV')).style.visibility = "hidden";
    document.getElementById(findByPartOfID("Panel2", 'DIV')).style.position = "absolute";
   
   
    document.getElementById(findByPartOfID("Panel3", 'DIV')).style.visibility = "hidden";
    document.getElementById(findByPartOfID("Panel3", 'DIV')).style.position = "absolute";
   
   
    document.getElementById(findByPartOfID(id, 'DIV')).style.visibility = "";
    document.getElementById(findByPartOfID(id, 'DIV')).style.position = "";
   
   
    // set button color here

document.getElementById(findByPartOfID("B1", 'INPUT')).style.backgroundColor = "";
document.getElementById(findByPartOfID("B2", 'INPUT')).style.backgroundColor = "";

document.getElementById(findByPartOfID("B3", 'INPUT')).style.backgroundColor = "";
document.getElementById(sender).style.backgroundColor = color;

}

<asp:Panel ID="Panel1" style="" runat="server">
<asp:Panel ID="Panel2" style="visibility:hidden;position:absolute;" runat="server">
<asp:Panel ID="Panel3" style="visibility:hidden;position:absolute;" runat="server">


 Response.Redirect("mypage.aspx?id=" & CInt(Request.QueryString("iclaimid")) & "&Type=" & Request.QueryString("type"))
 
 
Avatar of DropZone
DropZone
Flag of United States of America image

Can you explain in more details?  I do not understand what you are trying to do, and what is the problem.

    -dZ.
Avatar of jaws1021
jaws1021

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");' />
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.
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.
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?
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.

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?

ASKER CERTIFIED SOLUTION
Avatar of DropZone
DropZone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<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.RegisterStartupScript(Me.GetType(), "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()

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.