2011-03-04 166 views
1

有時,帶參數的鏈接會調出參數,有時不會。如果我打開IE瀏覽器,並在其他選項卡中執行操作,並嘗試點擊其中的參數鏈接,它會進入主屏幕。如果我點擊沒有打開IE的鏈接,它會通過參數進入站點。請幫忙!不帶參數的ASP鏈接

示例鏈接:http://ServerName/time_and_attendance/?timesheet_id=7489

代碼如下:

<!--#INCLUDE virtual="/time_and_attendance/i_time_attendance_header.asp" --> 
<% 
'--------------------------------------------------------------------------------------------------------------------- 
'JFV 6-10-2010: Will need these lines uncommented and inserted above the '<!--#INCLUDE' line 
' to be used in the alternate e-mail configuration 
'<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Type Library" --> 
'<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" --> 
'--------------------------------------------------------------------------------------------------------------------- 
%> 
<% 
'If there is not a timesheet id send user back to their employee page 
If Request("timesheet_id")<>"" Then 
    my_employees_timesheet_id=Request("timesheet_id") 
    RedirectUrl="my_employees_timesheet.asp?timesheet_id="&Request("timesheet_id") 
    'Response.Write my_employees_timesheet_id 
Else 
    Response.Redirect("default.asp") 
End If 
%> 

回答

4

您應該使用Request.Querystring,而不是簡單RequestTrim值使用它之前。

另外,dim變量並首先將參數檢索到變量中。

dim ts_id 

ts_id = trim(request.querystring("timesheet_id")) 

If ts_id <>"" Then 

    my_employees_timesheet_id=ts_id 

    RedirectUrl="my_employees_timesheet.asp?timesheet_id="&ts_id 

    'Response.Write my_employees_timesheet_id 

Else 

    Response.Redirect("default.asp") 

End If 
+0

工作就像一個魅力!我感謝幫助! – JFV 2011-03-04 20:38:01