473,323 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Pass Windows User (domain\userid) to report url in ASCX page

200 100+
Good day, not sure what to do.

I have an ascx page with the code displaying the user logged in, i created an iframe src displaying a report but i want to add the logged in id as parameter but can't determine the code value.

ascx page code
Expand|Select|Wrap|Line Numbers
  1. <%@ Control Language="c#" AutoEventWireup="True" Codebehind="Header.ascx.cs" Inherits="FlowCentric.Net.Navigator.Header" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
  2. <tr>            
  3. <td><asp:Label id="lblLogin" runat="server">Welcome</asp:Label></td>
  4.  </tr>
  5.  
the iframe report i add & add the user parameter to the label's lblLogon value.
Expand|Select|Wrap|Line Numbers
  1.  <IFRAME id="frame1" src="http://biweb/reportserver?&User=lblLogin"</IFRAME>    
  2.  
Please Assist, totally lost
Apr 18 '09 #1
34 7975
Frinavale
9,735 Expert Mod 8TB
Get rid of the "&"....it should be like:
Expand|Select|Wrap|Line Numbers
  1. <IFRAME id="frame1" src="http://biweb/reportserver?User=lblLogin"</IFRAME>    
Another problem you're having is that you aren't actually passing the innerHtml of the Label...

I would recommend using a Session variable instead of passing it via the URL because it's going to be complicated....it's going to require using JavaScript to retrieve the innerHtml of the <span> element (Labels are rendered as <span> elements) to retrieve the login name. Then you'll have to use JavaScript to set the src of the iFrame element.

It's doable but using Session variables is a lot easier and cleaner.

-Frinny
Apr 20 '09 #2
ismailc
200 100+
Thank You vey much - tried a few things.

But i will try & and get the code for asp to determine the windows user & pass as a parameter for the report.
Apr 20 '09 #3
Frinavale
9,735 Expert Mod 8TB
I don't think you understood.
It's more than just removing the "&".....

If you're going to pass a value using the URL you need to retrieve the value Client Side using JavaScript and then set the src of the iFrame using JavaScript.
Apr 20 '09 #4
ismailc
200 100+
Good day, This is linked to my previous post.

I want to display the Windows user logged on to the PC (domain\userid) and add to the report URL.

I have searched:
Expand|Select|Wrap|Line Numbers
  1. <% Response.Write(Request.ServerVariables("AUTH_user")) %>
  2.  
Now i want to display & add to url:
Expand|Select|Wrap|Line Numbers
  1. <%@ Control Language="c#" AutoEventWireup="True" Codebehind="Header.ascx.cs" Inherits="FlowCentric.Net.Navigator.Header" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
  2. <table><tr>
  3. <td><asp:Label id="lblLogin" runat="server">We</asp:Label></td>               
  4. </tr></table>
  5.  
  6.  <IFRAME id="frame1" src="http://biweb/reportserver?&User= <% Request.ServerVariables("AUTH_user") %>"></IFRAME>    
  7.  
  8.  
  9. <% Response.Write(Request.ServerVariables("LOGon_user")) %>  <!-- this does not work
  10.  
Please Assist!
Apr 20 '09 #5
Frinavale
9,735 Expert Mod 8TB
I've merged your questions together.
Is "http://biweb/reportserver" in the same web application as the other page?
In that case your user's information should already be available in the ReportServer.aspx page.

-frinny
Apr 20 '09 #6
ismailc
200 100+
Thank You for the help, the reports are from the BiReportServer

where would i find & extract the information from the reportserver.aspx.

I need to pass the loged in user id to the report parameter.

Please Assist with detail code.
Apr 20 '09 #7
Frinavale
9,735 Expert Mod 8TB
Are both pages part of the same web application??

If so, and you're using Windows Authentication, then you should be able to access the user information using the HttpContext.User property in both pages.

Once a user has logged in a Principal Object is created to represent the user. This Principal Object is recreated every time the user accesses a page in the web application. It's created before your code is accessed so that ASP.NET can determine whether or not the user has permissions to access your code. This Principal Object (which represents your user) is stored in the HttpContext.User property which is available to you through out your web application (in any page).

This contains the User's ID along with other user information.
Apr 20 '09 #8
ismailc
200 100+
Unfortnuately they are different servers.
Apr 20 '09 #9
ismailc
200 100+
Any other ideas, please?
Apr 20 '09 #10
Frinavale
9,735 Expert Mod 8TB
Well you need to append the ID of the user stored in the Label (the <span> element representing the Label) to the src (URL) of the iFrame.


To do this you're going to have to use JavaScript.

You could do something like:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.   function setIFrameSource()
  3.   {
  4.      var labelElement = document.getElementById('<%=Request.ServerVariables("AUTH_user")');
  5.      var newUrl = "http://biweb/reportserver?UserID=" + labelElement.innerHTML;
  6.  
  7.      var iFrameElement = document.getElementById("frame1");
  8.      iFrameElement.src = newUrl;
  9.   }
  10. </script>
  11.  
You'd call it during the <body> element's onload event:

Expand|Select|Wrap|Line Numbers
  1. <body onload="setFrameSource">
Please note that spaces will mess up your URL...this means that if your user name has a space you need to remove them and replace it with %20.

Also please note that you have to grab the UserID value from the URL. The easiest way to do this is using Request.Params("UserID"). Always validate this information.
Apr 20 '09 #11
ismailc
200 100+
Hi,

It does not like the line
var labelElement = document.getElementById('<%=Request.ServerVariable s("AUTH_user")');

no error message, only incorrect syntax

regards
Apr 20 '09 #12
Frinavale
9,735 Expert Mod 8TB
Hehe, well of course it's incorrect...the word processor here on bytes doesn't automatically close tags like Visual Studio does


Close the "<%= " with "%>".

Like this:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.   function setIFrameSource()
  3.   {
  4.      var labelElement = document.getElementById('<%=Request.ServerVariables("AUTH_user") %>');
  5.      var newUrl = "http://biweb/reportserver?UserID=" + labelElement.innerHTML;
  6.  
  7.      var iFrameElement = document.getElementById("frame1");
  8.      iFrameElement.src = newUrl;
  9.   }
  10. </script>
  11.  
My syntax isn't always going to be 100% because I'm just writing quick examples of code...you're going to have to check it and even correct it sometimes to make sure it's working ;)

But the above code is incorrect anyways (because you don't have a Label with the ID that is UserID...instead it should be Label.ClientID). You don't actually need to grab the user ID from the label...you can just simply grab it from the server.


Change it to:


Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.   function setIFrameSource()
  3.   {
  4.  
  5.      var newUrl = "http://biweb/reportserver?UserID=" + "<%=Request.ServerVariables("AUTH_user") %>";
  6.  
  7.      var iFrameElement = document.getElementById("frame1");
  8.      iFrameElement.src = newUrl;
  9.   }
  10. </script>
  11.  
Please note that the ASP code "<%=" is the same as having "<% Response.Write() %>"...it's just the short hand version.
Apr 20 '09 #13
ismailc
200 100+
Thank You i really appreciate your help & am very gratefull.

Unfortunately still struggling:

It still complains about the 1st line in the javascript:
Expand|Select|Wrap|Line Numbers
  1. <%@ Control Language="c#" AutoEventWireup="True" Codebehind="Header.ascx.cs" Inherits="FlowCentric.Net.Navigator.Header" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
  2.  
  3.  
  4. <script type="text/javascript"> 
  5.   function setIFrameSource() 
  6.   { 
  7.  
  8.      var newUrl = "http://biweb/reportserver?&User=" + <% Response.Write(Request.ServerVariables("AUTH_user")) %>; 
  9.  
  10.      var iFrameElement = document.getElementById("frame1"); 
  11.      iFrameElement.src = newUrl; 
  12.   } 
  13. </script>
  14.  
  15. <body onload="setFrameSource">
  16.  
  17. <table><tr>            
  18. <td><asp:Label id="lblLogin" runat="server">Wel</asp:Label></td>               
  19.  </tr></table>
  20. </body>
  21.  
  22.  
Please Assist, my only hope - i dont know the code at all & only know the reports.

Regards
Apr 20 '09 #14
Frinavale
9,735 Expert Mod 8TB
Why do you have an "&" in there?
Also, you need quotes around:

<% Response.Write(Request.ServerVariables("AUTH_user" )) %>

That is going to write text into the place where the Response.Write line is.
You need to specify that this text should be treated as a literal (a String) by putting quotes around it:

"<% Response.Write(Request.ServerVariables("AUTH_user" )) %>";
Apr 20 '09 #15
ismailc
200 100+
Hi, this is not the complete link to the report, & identifes the pass of a variable
User is the report parameter name, the "ismail" is the id i'm trying to retreive from the aspx page.

comple link
Expand|Select|Wrap|Line Numbers
  1. http://biweb/reportserver?http%3a%2f%2fsrv08-za143%2fworkspace%2fdepartments%2fIT%2fReportsTest%2fR-MFS014+UserDetails.rdl&rs:Command=Render&User=ismail"
  2.  
Apr 20 '09 #16
Frinavale
9,735 Expert Mod 8TB
Please post error messages if you see them.
Apr 20 '09 #17
ismailc
200 100+
Expand|Select|Wrap|Line Numbers
  1. Line 8:       var newUrl = "http://biweb/reportserver?http%3a%2f%2fsrv08-za143%2fworkspace%2fdepartments%2fIT%2fReportsTest%2fR-MFS014+UserDetails.rdl&rs:Command=Render&rc:Toolbar=false&User=" + <% Response.Write(Request.ServerVariables("AUTH_user")) %>; 
  2.  
  3.  
error: c:\Inetpub\wwwroot\fcParmalatTest\Header.ascx(8,24 2): error CS1002: ; expected
Apr 20 '09 #18
Frinavale
9,735 Expert Mod 8TB
Please add quotes around the ASP Response.Write() method... use this:

Expand|Select|Wrap|Line Numbers
  1. var newUrl = "http://biweb/reportserver?http%3a%2f%2fsrv08-za143%2fworkspace%2fdepartments%2fIT%2fReportsTest%2fR-MFS014+UserDetails.rdl&rs:Command=Render&rc:Toolbar=false&User=" + "<% Response.Write(Request.ServerVariables("AUTH_user")) %>"; 
Apr 20 '09 #19
ismailc
200 100+
No luck, i tried ithout the " + " as well
Apr 20 '09 #20
ismailc
200 100+
I tried
Expand|Select|Wrap|Line Numbers
  1. var newUrl = "http://biweb/reportserver?http%3a%2f%2fsrv08-za143%2fworkspace%2fdepartments%2fIT%2fReportsTest%2fR-MFS014+UserDetails.rdl&rs:Command=Render&rc:Toolbar=false&User=" + "<%=Request.ServerVariables("AUTH_user")%>";
  2.  
and get the following error:
error CS1955: Non-invocable member 'System.Web.HttpRequest.ServerVariables' cannot be used like a method.


Please Assist, Regards
Apr 20 '09 #21
Frinavale
9,735 Expert Mod 8TB
Oh.

Are you working in C#?
Apr 20 '09 #22
ismailc
200 100+
I'm only editing the ASCX page (this is the page's entire code above)
the codebehind uses C#, which i don't have & know.

I was asked to see if i can add more information on the header page from the db, so i wrote a report but now can't pass the logged on user from the apsx page
Apr 20 '09 #23
Frinavale
9,735 Expert Mod 8TB
@ismailc
I thought that's what we're trying to solve right now?


Please see MSDN for information about the HttpRequest.ServerVariables property.


It returns you an Array of NameValueCollection Objects...you are treating it like a Method because you are using round brackets "()"...when you should be treating it like an array by using square brakets "[]".

Could you do me a favour and post the code you're using to write the user name into the Label?
Apr 20 '09 #24
ismailc
200 100+
Hi, Winning a bit & getting excited (23:00) in S.A.

Changing the code to
Expand|Select|Wrap|Line Numbers
  1. &User=" + "<%=Request.ServerVariables["AUTH_USER"]%>";
  2.  
works but nothing outputs on thescreen, does not display the report as previous.
looked at the source of the page.
Expand|Select|Wrap|Line Numbers
  1. &User=" + "ZA\ismailc";
  2.  
The report works with this value but it does not display on the page

should i not add this <body onload="setIFrameSource"> to an iframe & how?

Regards
Apr 20 '09 #25
Frinavale
9,735 Expert Mod 8TB
The iFrame element supports the onload event.....

I'm not sure what you're asking...but you can call the "setIFrameSource()" method during the iFrame's onload event if you want:

Expand|Select|Wrap|Line Numbers
  1. <iframe id="frame1" onload="setIFrameSource()"></iframe>
Apr 20 '09 #26
ismailc
200 100+
Apologies, but now i have an other problem.

I pass the value & look at the source, for the value za\ismailc
the link passes ZA%5cismailc - it replaces the "\" with "%5c"

in the page code can i perhaps substring the text by removing the "za\" and returning evrything thereafter.

Please Assist and Thank You for your patience and help.
Apr 20 '09 #27
ismailc
200 100+
Thank You very much, really could not do this without you.

<%=(Request.ServerVariables["AUTH_USER"]).Substring(3)%>

Thank You :)
Apr 20 '09 #28
Frinavale
9,735 Expert Mod 8TB
The backslash ("\") is converted to %5 because "\" is a special character.
It's an "escape" character....so that it negates things that would normally have a meaning.

For example "\n" would print a new line.
But "\\n" prints "\n".

So in order to print a "\" you have to escape out the escape character like:
"\\"

For security reasons ASP.NET converts these characters into their ASCII value....%5 is the ASCII value for \

This way they aren't treated as special characters.

Consider removing the \ in the server side code.

Like:

<%=Request.ServerVariables["AUTH_USER"].split("\\")[1];%>

(Please note that this will throw an exception if the split is unsuccessful.)
Apr 20 '09 #29
Frinavale
9,735 Expert Mod 8TB
Oh you answered your question before I could finish answering it.
The SubString method works well too :D

I'm glad you solved it!

-Frinny
Apr 20 '09 #30
ismailc
200 100+
Impossible without you :)

Keep well, hope i don't bother you soon.

Thank You
Apr 20 '09 #31
Hi,
I have a similar issue where I am trying to pass the user ID from a WSS V3 site to an Oracle Forms Application server...do you think this approach can help?
May 11 '09 #32
Frinavale
9,735 Expert Mod 8TB
The solution discussed above helps to pass information from a web page to another web page.

I don't know if it will work with Windows SharePoint Services because I've never really used them before.

Are you using Web Pages to access both the Windows SharePoint Service and your Oracle Forms Application?

What are you trying to do?
May 11 '09 #33
I have a Sharepoint site (WSS) that will be calling a aspx document through a page viewer web part. In this aspx document is code that pulls the current user id (including domain) then displays it. The document also has JavaScript that starts a form applet via an Oracle Forms Application Server.

Problem:
Trying to get that user id :(<xsl:param name="LogonUser"/>) into the JS code: (document.writeln('<PARAM NAME="serverArgs" VALUE="module=svilsim.fmx' + ' userid='+ getParm('vsuccess') + ' Name=' + vparam +'">');)
so that no login is required by the user when they access this page.
May 13 '09 #34
I was trying to recreate this and got this error:

An error occurred during the compilation of the requested file, or one of its dependencies. ; expected
May 21 '09 #35

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Chad | last post by:
Alright, I've been searching all over and it seems I'm just not looking for the right thing, since what I want to do seems extremely simple I just don't know the correct syntax. All I get is how to...
2
by: Niclas Lindblom | last post by:
Hi, I would like to use a separate stylesheet for a .ascx module without changning the stylesheet that is referenced in the .aspx page <HEAD> section Is it possible to reference another...
5
by: Jay Douglas | last post by:
I have a set of pages that inherit from a base class in the App_Code folder. The class looks something like: public class MyBaseClass : System.Web.UI.Page In various stages of the life cycle I...
1
by: Bharath | last post by:
Hi All, I'm embedding a windows user control in aspx page and showing the user control in the IE, the problem that I'm facing is that the user session of the parent application is getting expired...
2
by: Brenden Bixler | last post by:
I have a user control, dropdown.ascx Inside dropdown.ascx, I have a dropdownlist control. From my page.aspx, I need to be able to access the dropdown's value. By setting it to auto-post...
2
by: krallabandi | last post by:
I have a hidden control <input id="FieldSortOrder" type="hidden" name="FieldSortOrder" runat="server"> in a ascx page. I want to store some value in this control in the code behind page. ...
7
by: Jason | last post by:
I am trying to dynamically add a web user control - ctrlBlogEntry.ascx - to a page - default.aspx - (via an ASP:PlaceHolder). This web user control has two ASP:Label controls and I'm accessing...
5
by: strikefiend | last post by:
Ok, I'm somewhat new to .NET C# language and am having a bit of trouble. I'm trying to run the javascript confirm() method from my ascx page but I'm currently using C# as the main language of the...
3
by: Montu76 | last post by:
Hi All, I want to pass values from .apsx page(textbox value) to .ascx page. Any sort of help will be appreciated. Regards
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.