0

I want to redirect to another page and pass some parameters only using javascript. I am not supposed to use query string. Is there any way to achieve this? I am working on asp.net.

I want this redirection to use with devexpress scheduler control where when a user clicks on an appointment, the user be redirected to another page by passing the selected appointment's ID as parameter. It should not be passed as query string.

I would also like to know how to retrieve such kind of invisible parameter from the redirected page.

Ok I found out my solution.

I used javascript to click a <asp:Button> that is set to style="display:none". In my scenario, I could get the properties of scheduler appointment that I had clicked. I then put these properties in hidden fields and in the server side click event of this 'invisible' button, I use these hidden field values to make my redirection through server side. My code is as below

<asp:Button ID="Appointment" runat="server" Text="sample" 
    onclick="Appointment_Click" style="display:none"/>
<asp:HiddenField ID="hfID" runat="server" />
<asp:HiddenField ID="hfSubject" runat="server" />
<asp:HiddenField ID="hfDate" runat="server" />

<script type="text/javascript" language="javascript">
    function OnAppointmentClick(s, e) {
        //debugger;
        var apt = scheduler.GetAppointmentById(e.appointmentId);

        var apt1 = scheduler.GetAppointmentProperties(e.appointmentId);

        var aptID = document.getElementById('<%= hfID.ClientID %>');
        var aptDate = document.getElementById('<%= hfDate.ClientID %>');
        var aptSubject = document.getElementById('<%= hfSubject.ClientID %>');
        aptID.value = e.appointmentId;
        var date = (apt.startDate.getMonth()+1) + '/' + apt.startDate.getDate() + '/' + apt.startDate.getYear(); 
        aptDate.value = date;
        aptSubject.value = apt.CODE;
        document.getElementById('<%= Appointment.ClientID %>').click();
    }    
    </script>
2
  • Is this your homework ? :) Commented Jul 8, 2013 at 5:14
  • No. This is my office work. I am working with devexpress scheduler. Commented Jul 8, 2013 at 6:54

2 Answers 2

3

Try this:

ASP.net Code:

Response.Headers.Add("id", "testtest");
Response.Redirect("http://www.somesite.com/somepage.aspx");

Java Script Code:

window.location = 'http://www.somesite.com/somepage.aspx?q=manvswild';

jQuery Code:

var url = "http://www.somesite.com/somepage.aspx?q=manvswild";
$(location).attr('href',url);

jQuery Ajax Code:

$.ajax({
    type : 'POST',
    url : 'page.aspx',
    data : {
        paramname1 : "put_param_value_here",
        paramname2 : "put_param_value_here",
        paramname3 : "put_param_value_here"
    },
    dataType : 'html',
    success : function (e) {
        window.location = e;
    }
});

// or short method is

$.post("page.aspx", {
    param1 : 'one',
    param2 : 'two'
}, function (data) {
    window.location = data;
});

jQuery plugin: http://plugins.jquery.com/project/query-object

alert($.query.set("section", 5).set("action", "do").toString());

Output:

?section=5&action=do
Sign up to request clarification or add additional context in comments.

2 Comments

Your answer is quite good one but I am not allowed to use query string due to security reasons.
@Nisha: Then try to manipulate with session in aspx. use session to pass param or you can use encrypt/decrypt with your secure data. Good Luck!!
1

try this document.location.href = "window-location.html"

already asked here

1 Comment

Sorry, but the link you provided does not talk about passing parameters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.