hello Members,

I have an ASP.NET website that uses an IFrame settings and I am using the response.redicret("...") to load a new page within the same IFrame. below is my
code snippet.

Response.Redirect ("../TrackApp/history2Display.aspx?deviceUID=" + DevUID + "&fromDate=" + startDate + "&endDate=" + endDate);

when the page redirects, I get a javascript error on the status bar stating that the fromDate is not define. However, when I look at the url posted to the page, the query string is attached correctly with the seclected values from the previous page posting the request.

Example error bellow.

Line: 161
Char: 2
Error: 'fromDate' is undefined
Code: 0;
URL: http://localhost:1651/TrackFusion/TrackApp/history2Display.aspx?deviceUID=227
&fromDate=9/10/2007%201:00:00%20AM&endDate=11/10/2007%201:00:00%20AM

As we can see, the values are posted to the url string. however, my javascript in the AJAX code cannot find the value for fromDate and presumably endDate.

I would appreciate any assistance I can get from anyone who understand what is going on.

try doing a test run and changing your fromDate to some kind of string to see if it is failing in that matter. You might need to encode the url for it (possibly by the command Server.UrlEncode?) or code the colons by (%3a). But first, I would try removing your current dates and put a simple string. Let me know if it comes up okay or if it still fails.

I once also had a problem that was fixed by making the "+" signs into "&". Doubt it will work, but it did for me once.

And can I see the code where you requested the querystrings? So far it doesn't seem like you would be missing something

Also.. Do you absolutely need the time part of the date? Try parsing it as fromDate.ToString("d") and eliminate the hours, minutes, and seconds portion

This page used to work fine with the following code.

string SCRIPT_TAB_HEAD = "<script language='javascript'>";
        string SCRIPT_TAB_TAIL = "'</script>";
        System.Text.StringBuilder html = new System.Text.StringBuilder();
        html.Append(SCRIPT_TAB_HEAD);

        string SCRIPT_BODY = "top.main.location.href='../TrackApp/main.aspx?selectedTab=10&deviceUID=";
        html.Append(SCRIPT_BODY);
        html.Append(DevUID);
        html.Append("&fromDate=");
        html.Append(startDate);
        html.Append("&endDate=");
        html.Append(endDate);

        html.Append(SCRIPT_TAB_TAIL);

        //register with ClientScript
        //The RegisterStartupScript method is also slightly different
        //from ASP.NET 1.x
        Type t = this.GetType();
        if (!ClientScript.IsClientScriptBlockRegistered(t, "Test1"))
            ClientScript.RegisterClientScriptBlock(t, "Test1", html.ToString())

The reason we changed the code is that when a user logged into our site, they were not able to go directly into their account unless they press on the background of a locate button object. When we changed the to the first posting, lab test shows that I can logged into the site and eventually be dump into the myAccount.aspx page automatically. thus allowing the page main.aspx to refresh and pickup the new value assigned to selectedTab.

I tried to use the Server.UrlEncoded("") and it fails big time.

Now, the place where I'm receiving the values is inside an AJAX script and the code is listed bellow.

function getTrack() 
{
    //alert("getting tracks");
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	//var url = "http://trackfusion.gpsit.com/Alpha2/bllWebServices/webServices.asmx/SelectedTrackList";
	var url = "../bllWebServices/webServices.asmx/SelectedTrackList";
	alert(url); 
	xmlhttp.open("POST", url, true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

	//xmlhttp.send("deviceUID="+DUID+"&fromDate="+fromDate+"&endDate="+endDate+"");
	xmlhttp.onreadystatechange = handleTrackResponse;
	xmlhttp.send("deviceUID=" + DUID + "&fromDate=" + fromDate + "&endDate=" + endDate);
}

All the above code used to work until we made the change to the Response.Redirect() methods. The Response.Redirect is the best implementation for what we need but the code is problematic in that regard.

SheSaidImaPregy if you need to test the code live send me a private email and I will set you up with a test account so you can have an inside look at the results. The current page is running the old implementation so I don't want to upload unverified code until I get it right.

are you referencing in the right device uid? It seems you are setting it to DUID and then retrieving it as DevUID. What I need to see now is where you are referencing it. I feel as if I am missing a big piece of code. You gave me the redirect, and the ajax part. Can I see the part where you reference in the ajax to the redirect?

I don't have that part of the code. The thing is I don't know what I have to do get that part working. Yes a big part of the underlying code is missing because it is to long to post on the blog. But most of the work that control the behavior of the site is a page called main.aspx. this page consist of several infragistics iframes and part of the code is bellow

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1"><title>
	Main Tracker Application
</title>
    
    <script language="javascript" type="text/javascript">

	  var query=this.location.search.substring(1);
	  var selectedTab = '5';
	  var newTab = '2';
	  if (query.length > 0)
	  {
		   var params=query.split("&");
	      for (var i=0 ; i<params.length ; i++)
	      {
	         
	         var pos = params[i].indexOf("=");
		      var name = params[i].substring(0, pos);
			   var fieldVal = params[i].substring(pos + 1);
		      
		      if (name == 'selectedTab')
		      {
			     selectedTab = fieldVal;
			  }
			  if(name == 'Tab2')
			  {
			        var newTab = fieldVal;
			        //alert("newTab's value = " + newTab);
			  }			   	
		      if (name == 'PID')
		      {
			    var pid = fieldVal;
			   }	
		     
		      if (name == 'deviceUID')
		      {
			    var duid = fieldVal;
			  }
			 
			   if (name == 'device')
			   {
			    var duid = fieldVal;
			   }
			 
			   if (name == 'username')
			   {
			    var username = fieldVal;
			   }
			 
			   if (name == 'deviceName')
			   {  
			    //alert(name);
			    var devName = fieldVal;
			   }
			   
			   if (name == 'trackUID')
			   {  
			    var trackUID = fieldVal;
			   }
			 
			   if (name == 'fromDate')
			   {  
			    //alert(name);
			    var fromDate = fieldVal;
			   }
			 
			   if (name == 'endDate')
			   {  
			    //alert(name);
			    var endDate = fieldVal;
			   }						
          }
       }
       
      
      function selectTab()
	   {
		   var tab = igtab_getTabById("UltraWebTab1");
			if(tab != null)
			{
			    if(selectedTab <= 6)
			    {
			        //alert("the selected tab is: " + selectedTab);
				    tab.setSelectedIndex(selectedTab);
				    top.contents.location.href="../ControlPanel/"+selectedTab+"panel.aspx";
				    changeTarget();
				}
				else
				{
				    //alert("the selected tab is: " + selectedTab);
				    tab.setSelectedIndex(selectedTab);
				    changeTarget();
				}
			}
		}
		
		function changeTarget()
		{
			// get value for the target url
			var url1 = "mapControllerIE_default.aspx?PID="+pid;
			url1 = url1 + "&requestedAcc=300&defAccuracy=15000&DUID=" + duid;
			
			//var url1a = "http://trackfusion.gpsit.com/mapcontrol/displayLocationUP.html?PID="+pid;
			//url1a = url1a + "&requestedAcc=300&defAccuracy=1500&DUID=" + duid;
			
			var url2  = "record2Display.aspx?TrackUID=" + trackUID;		
			var url2a = "history2Display.aspx?DUID=" + duid + "&fromDate=" + fromDate + "&endDate=" + endDate;			
			var url3 = "../myDevices/myDevices.aspx?DUID=" + duid;
			var url4 = "../Scheduler/newTrackRecorderUI.aspx?DUID="+ duid + "&PID=" + pid + "&deviceName=" + devName;
			var url5 = "../Alerts/newAlertsUI.aspx?DUID=" + duid + "&PID=" + pid + "&deviceName=" + devName;
			var url6 = "../History/newTrackHistoryUI.aspx?DUID=" + duid + "&PID=" + pid + "&deviceName=" + devName;
						
			var url8 = "../Geofences/geofence.htm?username=" + username + "&device=" + devName + "&DUID=" + duid;			
			var url8a = "../Geofences/settings.htm?username=" + username + "&device=" + devName + "&DUID=" + duid;
			
						
			var url8b = "../Geofences/schedule.htm?loc=00&username=" + username + "&device=" + duid;
			var url8c = "../Geofences/group.htm?loc=00&username=" + username + "&device=" + duid;
			var url8d = "../Geofences/history.htm?loc=00&username=" + username + "&device=" + duid;
			var url8e = "../Geofences/alerts.htm?loc=00&username=" + username + "&device=" + duid;
			
			
			
			
			//var urlblank = "blankmap.html?GoTo=0";
			// get reference to the script object that represents UltraWebTab
			
			// [12] =BMF or Control Plane device
			var url12 = "mapControllerIE.aspx?PID="+pid;
			url12 = url12 + "&requestedAcc=30000&defAccuracy=1500&DUID=" + duid;
			
			// [13] = User Plane device
			var url13 = "mapControllerIE_UP.aspx?PID="+pid;
			//url13 = url13 + "&requestedAcc=30000&defAccuracy=1500&DUID=" + duid;
			
			
			var tab = igtab_getTabById("UltraWebTab1");
			if(tab != null)
			{
				if (selectedTab == '0')
				{
					var locationMap = tab.Tabs[0];
					locationMap.setTargetUrl(url1);
				}
				if (selectedTab == '1')
				{
				    if(newTab == '0')
				    {
				        var GotoGeoTab = tab.Tabs[1];
					    GotoGeoTab.setTargetUrl(url8);
					}
					else if(newTab == '1')
					{
					    var GeoSettings = tab.Tabs[1];
					    GeoSettings.setTargetUrl(url8a);
					}
				}
				if (selectedTab == '2')
				{
					var alertsTab = tab.Tabs[2];
					alertsTab.setTargetUrl(url5);
				}
				if (selectedTab == '3')
				{
				    var setSchedule = tab.Tabs[3];
				    setSchedule.setTargetUrl(url4);
				}
				if (selectedTab == '4')
				{
				    var trackHistory = tab.Tabs[4];
				    trackHistory.setTargetUrl(url6);
				}
			    if (selectedTab == '6')
			    {
			        var myDevicesTab = tab.Tabs[6];
			        myDevicesTab.setTargetUrl(url3);
			    }
				if(selectedTab == '9')
				{
					var q = tab.Tabs[0];
					q.setTargetUrl(url1a);
				}
				if (selectedTab == '8')
				{
				    var logout = tab.Tabs[0];
				    logout.setTargetUrl(url1a);
				}
				if(selectedTab == '10')
				{
				    var historydata = tab.Tabs[0];
				    historydata.setTargetUrl(url2a);
				    
				}
				if(selectedTab == '11')
				{
				    var showScheduleTrack = tab.Tabs[0];
				    showScheduleTrack.setTargetUrl(url2);
				}
				if(selectedTab == '12')
				{
				    var locateBMFTrack = tab.Tabs[0];
				    locateBMFTrack.setTargetUrl(url12);
				}
				if(selectedTab == '13')
				{
				    var locateUPTrack = tab.Tabs[0];
				    locateUPTrack.setTargetUrl(url13);
				}
			}
		}
		
		
		</script>
    
</head>

The above is the top portion that loads the new url base on the user's selection. However, the code bellow are default url that gets loaded when the click on one of the tabs.

<body style="margin-top: 0px; margin-left: 0px; margin-right: 0px;" onload="selectTab();">
    <form id="form1" runat="server">
    <div>
        <igtab:UltraWebTab ID="UltraWebTab1" runat="server" EnableAppStyling="False" Height="100%"
                            StyleSetName="Default" Width="100%" BorderStyle="Solid" BorderWidth="0px" 
                            DummyTargetUrl="../blankmap.htm" LoadAllTargetUrls="False" ThreeDEffect="False" SelectedTab="0">
            <Tabs>
                <igtab:Tab Text=" LOCATION MAP" SelectedImage="./arrow.gif">
                    <ContentPane TargetUrl="mapControllerIE_default.aspx" BorderStyle="None" BorderWidth="0px"></ContentPane>
                </igtab:Tab>
                <igtab:Tab Text=" GEOFENCES" SelectedImage="./arrow.gif">
                    <ContentPane TargetUrl="../Geofences/blank.htm" BorderStyle="None" BorderWidth="0px"></ContentPane>
                </igtab:Tab>
                <igtab:Tab Text=" ALERTS" SelectedImage="./arrow.gif">
                    <ContentPane TargetUrl="../Alerts/newAlertsUI.aspx" BorderStyle="None" BorderWidth="0px"></ContentPane>
                </igtab:Tab>
                <igtab:Tab Text=" TRACK RECORDER" SelectedImage="./arrow.gif">
                    <ContentPane TargetUrl="../scheduler/newTrackRecorderUI.aspx" BorderStyle="None" BorderWidth="0px"></ContentPane>
                </igtab:Tab>
                <igtab:Tab Text=" TRACK HISTORY" SelectedImage="./arrow.gif">
                    <ContentPane TargetUrl="../History/newTrackHistoryUI.aspx" BorderStyle="None" BorderWidth="0px"></ContentPane>
                </igtab:Tab>
                <igtab:Tab Text=" MY ACCOUNT" SelectedImage="./arrow.gif">
                    <ContentPane TargetUrl="../myAccount/newMyAccountUI.aspx" BorderStyle="None" BorderWidth="0px"></ContentPane>
                </igtab:Tab>
                <igtab:Tab Text=" MY DEVICES" SelectedImage="./arrow.gif">
                    <ContentPane TargetUrl="../myDevices/myDevices.aspx" BorderStyle="None" BorderWidth="0px" Scrollable="Hidden"></ContentPane>
                </igtab:Tab>
                <igtab:Tab Text=" CUSTOMER CARE" SelectedImage="./arrow.gif">
                    <ContentPane TargetUrl="../customerCare/customerCare.aspx" BorderStyle="None" BorderWidth="0px"></ContentPane>
                </igtab:Tab>
                <igtab:Tab Text=" SIGN OUT" SelectedImage="./arrow.gif">
                    <ContentPane TargetUrl="../GPSit_Login/logout.aspx?deviceUID=DUID" BorderStyle="None" BorderWidth="0px"></ContentPane>
                </igtab:Tab>
            </Tabs>
            <DefaultTabStyle BackColor="LightSlateGray" BorderStyle="Solid" BorderWidth="1px"
                Font-Names="Arial" Font-Size="9px" ForeColor="WhiteSmoke">
                <BorderDetails ColorBottom="Gray" ColorLeft="Gray" ColorRight="Silver" ColorTop="Gainsboro"
                    WidthBottom="0px" WidthLeft="1px" WidthRight="1px" WidthTop="1px" />
                <Margin Bottom="2px" Left="2px" Right="2px" Top="2px" />
                <Padding Bottom="2px" Left="10px" Right="10px" Top="7px" />
            </DefaultTabStyle>
            <HoverTabStyle BackColor="#CC6600" BorderStyle="Solid" BorderWidth="1px" Cursor="Hand"
                Font-Names="Arial" Font-Size="9px" ForeColor="WhiteSmoke">
                <BorderDetails ColorBottom="Gray" ColorLeft="Gray" ColorRight="Silver" ColorTop="Gainsboro"
                    WidthBottom="0px" WidthLeft="1px" WidthRight="1px" WidthTop="1px" />
                <Margin Bottom="2px" Left="2px" Right="2px" Top="2px" />
                <Padding Bottom="2px" Left="10px" Right="10px" Top="7px" />
            </HoverTabStyle>
            <SelectedTabStyle BackColor="#EFEFEB" BorderStyle="Solid" BorderWidth="1px" Cursor="Hand"
                Font-Names="Arial" Font-Size="9px" ForeColor="Gray">
                <BorderDetails ColorTop="DarkOrange" WidthBottom="0px" WidthLeft="1px" WidthRight="1px"
                    WidthTop="4px" />
                <Margin Bottom="2px" Left="2px" Right="2px" Top="2px" />
                <Padding Bottom="2px" Left="10px" Right="10px" Top="7px" />
            </SelectedTabStyle>
        </igtab:UltraWebTab>
        &nbsp;</div>
    </form>
</body>
</html>

all selection get posted to main.aspx and once the selected page loads, it loads the value that posted in main.aspx.

it should work. The only thing that I saw was the difference of your first code and the second. I'll get to that ina minute.. but first, why have this twice? Seem's illogical, but okay!

if (name == 'deviceUID')
{
var duid = fieldVal;
}
if (name == 'device')
{
var duid = fieldVal;
}
this should be something like:
if (name == 'device' || name == 'deviceUID') {
var duid = fieldVal;
}

Anyway.. :)

let's see.. have you tried replacing in your code the duid back to DevUID how it was in the previous code? As from your old code (the one that works), it references in DevUID and it works. Since I cannot see the rest, maybe DUID is not being set correctly. Try replacing the "duid" with "DevUID". Otherwise, you answered my previous question, but we still cannot see where duid and devuid is set. Or, instead, just add the line of code to your code:
var duid = DevUID;
and see if that works. From what I can see, duid is never truly set until after when it is called. But we're still missing code. Anyway, your best bet is to stick with the same vars as was previously used. Try that, otherwise NO CLUE :( Sorry.

if that doesn't work, then try changing your response.redirect's variable "DevUID" to "duid". Otherwise, code seems to be correct.

I tried all of the above and nothing works. I am entertaining the idea of parsing the query string via JavaScript. After all, I do know that the formated query string arrives to the redirected page with no problem. But, the value that should be assign to the AJAX variable is not being assign. Thus if I parse the query within the page, I should be able to set the variable's value (just a thought).

This article has been dead for over six months. Start a new discussion instead.