Passing username in a Url Of Links Module

Last post 09-02-2005 6:04 PM by autolibse. 18 replies.

Sort Posts:

  • Cool [cool] Passing username in a Url Of Links Module

    08-06-2005, 7:32 PM
    • Member
      205 point Member
    • autolibse
    • Member since 03-16-2005, 4:36 PM
    • Posts 43
    I want to pass the username logged on using the Links Module to another website. How can I access the username or any user field for that matter in the Links Module?
  • Re: Passing username in a Url Of Links Module

    08-07-2005, 12:10 AM
    • Contributor
      3,090 point Contributor
    • DougV
    • Member since 02-23-2004, 4:27 PM
    • Missouri
    • Posts 618
    Here is a snippet which I've used to give all kinds of information about the current User.

                Dim s As String
                Dim objUsers As New UserController

                Dim objUser As UserInfo = objUsers.GetUser(UserInfo.PortalID, UserInfo.UserID)
                s = "<table cellpadding=" & Chr(34) & "4" & Chr(34) & "bordercolor=" & Chr(34) & "teal" & Chr(34) & "bgcolor=#ffffc0 border=" & Chr(34) & "2" & Chr(34) & ">"
                s = s + "<tbody>"
                s = s + "<tr><td><b>" & "Variable" & "</b></td><td><b>" & "Value" & "</b></td></tr>"
                s = s + "<tr><td>" & "UserInfo.UserID" & "</td><td>" & UserInfo.UserID.ToString() & "</td></tr>"
                s = s + "<tr><td>" & "UserInfo.PortalID" & "</td><td>" & UserInfo.PortalID.ToString() & "</td></tr>"
                s = s + "<tr><td>" & "FirstName" & "</td><td>" & objUser.FirstName & "</td></tr>"
                s = s + "<tr><td>" & "LastName" & "</td><td>" & objUser.LastName & "</td></tr>"
                s = s + "<tr><td>" & "Street" & "</td><td>" & objUser.Profile.Street & "</td></tr>"
                s = s + "<tr><td>" & "City" & "</td><td>" & objUser.Profile.City & "</td></tr>"
                s = s + "<tr><td>" & "Region" & "</td><td>" & objUser.Profile.Region & "</td></tr>"
                s = s + "<tr><td>" & "PostalCode" & "</td><td>" & objUser.Profile.PostalCode & "</td></tr>"
                s = s + "<tr><td>" & "Country" & "</td><td>" & objUser.Profile.Country & "</td></tr>"
                s = s + "<tr><td>" & "Unit" & "</td><td>" & objUser.Profile.Unit & "</td></tr>"
                s = s + "<tr><td>" & "Telephone" & "</td><td>" & objUser.Profile.Telephone & "</td></tr>"
                s = s + "<tr><td>" & "Cell" & "</td><td>" & objUser.Profile.Cell & "</td></tr>"
                s = s + "<tr><td>" & "Fax" & "</td><td>" & objUser.Profile.Fax & "</td></tr>"
                s = s + "<tr><td>" & "Website" & "</td><td>" & objUser.Profile.Website & "</td></tr>"
                s = s + "<tr><td>" & "IM" & "</td><td>" & objUser.Profile.IM & "</td></tr>"
                s = s + "<tr><td>" & "TimeZone" & "</td><td>" & Str(objUser.Profile.TimeZone) & "</td></tr>"
                s = s + "<tr><td>" & "PreferredLocale" & "</td><td>" & objUser.Profile.PreferredLocale & "</td></tr>"


  • Cool [cool] Re: Passing username in a Url Of Links Module

    08-27-2005, 4:48 PM
    • Member
      205 point Member
    • autolibse
    • Member since 03-16-2005, 4:36 PM
    • Posts 43
    I setup a small module to retrieve the users values. How can I:

    Open a webpage in a new window passing the users name and id in a querry string
  • Re: Passing username in a Url Of Links Module

    08-29-2005, 9:31 AM
    • Contributor
      3,090 point Contributor
    • DougV
    • Member since 02-23-2004, 4:27 PM
    • Missouri
    • Posts 618
  • Re: Passing username in a Url Of Links Module

    08-29-2005, 3:17 PM
    • Member
      205 point Member
    • autolibse
    • Member since 03-16-2005, 4:36 PM
    • Posts 43
    But how can I open a new window and pass variables? 
  • Re: Passing username in a Url Of Links Module

    08-29-2005, 5:09 PM
    • Contributor
      3,090 point Contributor
    • DougV
    • Member since 02-23-2004, 4:27 PM
    • Missouri
    • Posts 618

    There's more than one way to do that.  Depends on how you want to go.  Here's one I use all the time.
    First, I went to my "js" directory and included the following file called newwin.js having code :

    <!-- hide this script from old browsers

    // http://powerhousedata.com
    // This script opens a new browser window and writes
    // HTML to display an image with a title and caption

    function show_view(pFileName,pTitle,pCaption,pScrolling) {
    // create iframe html with pFileName inside of it
    var s1 = '<IFRAME NAME=\"I1\" SRC=\"';
    var s2 = '\" HEIGHT=\"450px\" WIDTH=\"750px\" TITLE=\"Cascading Style Sheet Results\" ALIGN=\"middle\" STYLE=\"border: 2px solid #666666\" SCROLLING=\"';
    var s3 = " Your browser does not support inline frames or is currently configured not to display inline frames. ";
    var s4 = "</IFRAME>";
    var i=0 ;
    s2 += pScrolling;
    s2 += '\">';
    a= "";
    s1 += pFileName + s2 + s3 +s4;

    //alert(s1);
    // specify window parameters
    TutorialWin = window.open("","photo","onLoad=window.focus(),width=850,height=650,menubar=no,status=no,scrollbars,resizable,screenX=20,screenY=40,left=80,top=20");
    TutorialWin.focus();

    // write content to window
      TutorialWin.document.writeln('<html><head><title>' + pTitle + '</title></head>'); 
      TutorialWin.document.writeln('<BODY BGCOLOR=White LINK=Gray VLINK=Gray> ');
      TutorialWin.document.writeln('<P STYLE="text-align: center"><font size=+2 face="arial,helvetica"><b>' + pTitle + '</b></font><br><hr></p>');
      // display iframe with pFileName inside of it
      TutorialWin.document.writeln('<P STYLE="text-align: center">'); 
      TutorialWin.document.writeln(s1);
      TutorialWin.document.writeln('<font face="arial,helvetica">');
      TutorialWin.document.writeln('<br><br>');
      TutorialWin.document.writeln(pCaption);
      TutorialWin.document.writeln('</font><br>');
      TutorialWin.document.writeln('&nbsp');
      TutorialWin.document.writeln('<font face="Arial, Helvetica" size="2" color=teal>');
      TutorialWin.document.writeln('Copyright &#169; 2005&nbsp;&nbsp;</font><font face="Arial, Helvetica" size="2" color="#993366">Powerhouse Data</font>');
      TutorialWin.document.writeln('<br><a href =" " onClick="self.close()">Close this window</a>');
      TutorialWin.document.writeln('&nbsp;<br><br></p></body></html>');
      TutorialWin.document.bgColor="lightyellow";
    //for (propertyName in TutorialWin.document)
    //for (propertyName in navigator)
    //TutorialWin.document.writeln(propertyName + "<br>");
    //TutorialWin.document.writeln("<br>navigator.appName="+navigator.appName);
    //TutorialWin.document.writeln("<br>TutorialWin.document.width="+TutorialWin.document.width);
      TutorialWin.document.close(); 

    }
    // done hiding from old browsers -->

    Then in my Text/HTML I can create a link and pass info to the new window.

    <A onmouseover="window.status='Click Here';return true" title="CSS Tutorial - Second View" onclick="show_view('/tutorials/CSS_Views/MyCSS_Skin_view%282%29.htm','Powerhouse Data Tutorials',&#13;&#10;'Your view should now match the above with the light green Header.','no');return false" href="/tutorials/CSS_Views/MyCSS_Skin_view%282%29.htm">You should see the light green Header </A>

    The information passed is a filename, Title, caption, and whether I want scrollbars or not.  You can view a sample of this code in action here at  http://www.powerhousedata.com/Tutorials/DNNTablelessSkinTutorialLessonOne/Page3/tabid/99/Default.aspx.  On that page there are three links each using this script - try it by clicking on "You should see the light green header"

  • Re: Passing username in a Url Of Links Module

    08-29-2005, 8:50 PM
    • Member
      205 point Member
    • autolibse
    • Member since 03-16-2005, 4:36 PM
    • Posts 43

    Thanks for the link info. What I was trying to do in the button below was to extract the user info and pass it in the url. Is there a way to open a new window like in links above except using the format I have below.Also my url is not working in passing both variables. Do you know what I might be doing wrong?

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

                Dim s As String
                Dim objUsers As New UserController
                Dim objUser As UserInfo = objUsers.GetUser(UserInfo.PortalID, UserInfo.UserID)
                '****************
                Dim StudentId As String
                Dim StudentName As String
                Dim url As String
                StudentId = objUser.Profile.IM()
                StudentName = objUser.Profile.LastName()
              
                url = "http://localhost/clublean/CourseSelection/DotNetNuke.aspx?name=" & StudentName & "studentnum=" & StudentId

                Response.Redirect(url)
               
            End Sub

  • Re: Passing username in a Url Of Links Module

    08-30-2005, 3:56 PM
    • Contributor
      3,090 point Contributor
    • DougV
    • Member since 02-23-2004, 4:27 PM
    • Missouri
    • Posts 618

    This will work:

    Dim s as new System.text.StringBuilder
    Dim objUsers As New UserController
    Dim objUser As UserInfo = objUsers.GetUser(UserInfo.PortalID, UserInfo.UserID)
    '***************
    'Build your redirect string here
    s.append("http://localhost/clublean/CourseSelection/DotNetNuke.aspx?name=")
    s.append(objUser.LastName)
    s.append("&studentnum=")
    s.append(objUser.Profile.IM)

    'Now redirect
    Response.Redirect(s.ToString())


     
  • Re: Passing username in a Url Of Links Module

    08-30-2005, 4:59 PM
    • Member
      205 point Member
    • autolibse
    • Member since 03-16-2005, 4:36 PM
    • Posts 43
    Thanks, but how can I redirect to a new window so I do not lose my focus with DNN? I do not see how I could use the link new window code you shared earlier. Thanks again for all you insight.
  • Re: Passing username in a Url Of Links Module

    08-30-2005, 6:15 PM
    • Member
      205 point Member
    • autolibse
    • Member since 03-16-2005, 4:36 PM
    • Posts 43
    Thanks for the code. Is there a way for the redirect to open in a new window? I do not see how the links new window (response above) could be integrated here in the vb code.
  • Re: Passing username in a Url Of Links Module

    08-30-2005, 6:29 PM
    • Member
      205 point Member
    • autolibse
    • Member since 03-16-2005, 4:36 PM
    • Posts 43
    Thanks for the code. Is there a way for the redirect to open in a new window? I do not see how the links new window (response earlier) could be integrated here in the vb code
  • Re: Passing username in a Url Of Links Module

    08-31-2005, 10:42 AM
    • Contributor
      3,090 point Contributor
    • DougV
    • Member since 02-23-2004, 4:27 PM
    • Missouri
    • Posts 618

    To open in new window don't use response.redirect, build some JScript & use response.write (client must open a new window):

    Dim s as new System.text.StringBuilder
    Dim myjs As New System.text.StringBuilder
    Dim objUsers As New UserController
    Dim objUser As UserInfo = objUsers.GetUser(UserInfo.PortalID, UserInfo.UserID)
    '***************
    'Build your URL string here
    s.append("http://localhost/clublean/CourseSelection/DotNetNuke.aspx?name=")
    s.append(objUser.LastName)
    s.append("&studentnum=")
    s.append(objUser.Profile.IM)

    'Now build javascript
    myjs.Append("<script type = 'text/javascript'>")
    myjs.Append(" window.open('" & s.ToString() & '")</script>")
    Response.Write(myjs.ToString())


  • Re: Passing username in a Url Of Links Module

    08-31-2005, 10:43 AM
    • Contributor
      3,090 point Contributor
    • DougV
    • Member since 02-23-2004, 4:27 PM
    • Missouri
    • Posts 618
    place it in your Button3_Click subroutine
  • Big Smile [:D] Re: Passing username in a Url Of Links Module

    08-31-2005, 4:49 PM
    • Member
      205 point Member
    • autolibse
    • Member since 03-16-2005, 4:36 PM
    • Posts 43
    Big Smile [:D]Thank you. The your code is what I was looking for.
  • Re: Passing username in a Url Of Links Module

    08-31-2005, 5:34 PM
    • Member
      205 point Member
    • autolibse
    • Member since 03-16-2005, 4:36 PM
    • Posts 43

    Any  ideas on how to add the following features to the new window:

    "height = 200, width = 400, status = yes, toolbar = no, menubar = no, location = no"

    What would the basic syntax be?

Page 1 of 2 (19 items) 1 2 Next >