Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
B

bgates1970

@bgates1970
About
Posts
20
Topics
9
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Issue w/ Javascript inside 64 bit browser
    B bgates1970

    The code below is suppose to auto logoff a user after 30 seconds. The problem is it works fine with 32 bit browsers but not at all in 64 bit browsers. The countDown() function gets called but it never executes the window.location. Any assistance would be appreciated! <script type='text/javascript'> var secondsRemaining = 30; var mhcTimer; function countDown() { secondsRemaining -= 1; if (secondsRemaining <= 0) { secondsRemaining = 0; window.location='login.aspx'; } } function startAutoLogoff() { if (mhcTimer) { return false; } else { mhcTimer = setInterval('countDown();', 1000); } } startAutoLogoff(); </script>

    JavaScript help javascript tools

  • Reading PDF Files on Remote Server [modified]
    B bgates1970

    I know this is sort of an old topic but with all the code snippets I've attempted I still can't get it to perform consistently. Essentially, I'm trying to open a PDF on a server that is not on the domain but a Workgroup. The IIS 6 server is on the domain and the files reside on the Workgroup server. I'm using VS2008/.NET 3.5 *** Code to Open File from ASP.NET page '\\Server1\contracts\newlondon.pdf

    Dim sFullPath As String = sServer + sFolder + sFile

    Dim wcClient As WebClient = New WebClient()

    Dim obj As UserManager = New UserManager
    obj.CreateIdentity("user1", "Server1", "password")

    Dim buffer As Byte() = wcClient.DownloadData(sFullPath)

    Response.ClearContent()
    Response.AddHeader("Content-Disposition", "inline; filename=userdoc" + oDocument.FileExtension.ToString)
    Response.ContentType = returnExtension(oDocument.ContentType.ToString)
    Response.AddHeader("content-length", buffer.Length.ToString)
    Response.BinaryWrite(buffer)

    obj = Nothing

    *** *** Create Identity (which I found on CodeProject)

    Declare Auto Function LogonUser Lib "advapi32.dll" (ByVal lpszUsername As String, _
    ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As Integer, _
    ByVal dwLogonProvider As Integer, ByRef phToken As IntPtr) As Integer

    Declare Auto Function CloseHandle Lib "kernel32.dll" (ByVal handle As IntPtr) As Boolean
    
    Public Sub CreateIdentity(ByVal User As String, ByVal Domain As String, ByVal Password As String)
        Dim tokenHandle As New IntPtr(0)
        Dim ret As Integer
        Dim LOGON32\_PROVIDER\_DEFAULT As Integer = 0
        Dim LOGON32\_LOGON\_NETWORK\_CLEARTEXT As Integer = 3
    
        tokenHandle = IntPtr.Zero
        Dim returnValue As Boolean = LogonUser(User, Domain, Password, LOGON32\_LOGON\_NETWORK\_CLEARTEXT, LOGON32\_PROVIDER\_DEFAULT, tokenHandle)
        If False = returnValue Then
            ret = Marshal.GetLastWin32Error()
            Throw New Exception("LogonUser failed with error code: " + ret.ToString)
        End If
        Dim id As New WindowsIdentity(tokenHandle)
        CloseHandle(tokenHandle)
        id.Impersonate()
    End Sub
    

    ***** I've had it working a couple times on my workstation but never from the webserver. I usually get "Unknown username or password" or "Access to ..... denied!" I have identity impersonate="true" in the Web.Config.

    modified on Thursday, November 11, 2010 10:55 AM

    ASP.NET csharp asp-net sysadmin windows-admin help

  • Version Calculator
    B bgates1970

    3880

    Database tutorial announcement

  • Version Calculator
    B bgates1970

    I understand Math for some people is very difficult. If you started at 1.1, using a Depth of 3 and started incrementing by 1 it would look like... 1.1, 1.2, 1.3, 1.1.1, 1.1.2, 1.1.3, 1.2.1, 1.2.2, 1.2.3... So 625 versions is right on according to your math. Sorry but using a depth of 5 would be quite a bit higher than 625. You are correct though I have gotten what I expected out of this forum... smart a$$ comments and nothing really substantive.

    Database tutorial announcement

  • Version Calculator
    B bgates1970

    sometimes its best to stay separated from reality

    Database tutorial announcement

  • Version Calculator
    B bgates1970

    LOL! This one takes the cake! Do the math! Do you realize the number of versions you would be compiling? By that time I hope the product is obsolete.

    Database tutorial announcement

  • Version Calculator
    B bgates1970

    a 1? You're significant other must be disappointed.

    Database tutorial announcement

  • Version Calculator
    B bgates1970

    I'm attempting to build a Version calculator that will increment based on a depth field. I need this to execute inside a Stored Proc. My depth is 5. For example, I have 1.1 so the next time I call the Stored Proc it will be 1.2, 1.3, 1.4, 1.5. After it fills up based on that depth I want it to go down to the next level so the next one would be 1.1.1. The next would be 1.1.2, 1.1.3, etc... Once that bottom version fills out it will only go up one level. ie: 1.2.1, 1.2.2, 1.2.3, ...

    Database tutorial announcement

  • Visual Studio 2008 Acting Weird
    B bgates1970

    I have a small website with just two pages. On one of those pages I have a Repeater which is essentially displaying some data. The last column in the Repeater contains a Hyperlink with the ImageUrl set to an image. The image size is 12x12 but when I run the project it's resizing it to 20x20. I have a separate project with the same identical CSS and Repeater code which runs just fine. Thoughts?

    ASP.NET csharp css visual-studio question discussion

  • Gridview Masters/Detail Question
    B bgates1970

    Inplace Edit in GridView
    Found it on Code Project... go figure!

    ASP.NET tutorial question help

  • Gridview Masters/Detail Question
    B bgates1970

    I attempted that but I still can't find the exact article.

    ASP.NET tutorial question help

  • Avoid Duplicate record insertion on page refresh(F5)
    B bgates1970

    How about clearing the fields/variables after insertion? Then before inserting you validate that data to make sure it exists.

    ASP.NET csharp asp-net tutorial

  • Gridview Masters/Detail Question
    B bgates1970

    Never under estimate the power of saving Bookmarks. I recently found a great example on-line showing you how to display the DetailsView inside the GridView. The problem... I didn't bookmark it. Essentially, if you clicked on the "Edit" link it would just expand that row and show the DetailsView underneath the record you selected. Could someone please provide a sample or link?

    ASP.NET tutorial question help

  • HoverMenu Inside Repeater Control
    B bgates1970

    I'm using ASP.NET 2.0, Visual Studio 2005, AJAX, C#. I have a search results page that lists out products that a user is searching for inside the Repeater control. I have an image inside every product that when a user clicks on it I need to query the database to get the data. All the samples I have found show code with the panel already populated with data. I want to do it on demand. I've attempted to use the DropDownExtender, HoverMenuExtender and PopupControlExtender with no luck.

    ASP.NET csharp database asp-net visual-studio algorithms

  • Accessing Files on another server using ASP.NET
    B bgates1970

    I'm trying to access XML files stored on another server via my ASP.NET 2.0 Web Application. I've tried the UNC path and even a mapped drive letter. I know this isn't a coding issue but security issue. Do I need to install IIS on the other server and setup the ASP user account to have access? Brent

    Web Development csharp asp-net sysadmin windows-admin security

  • Accessing Files on another Server
    B bgates1970

    I'm trying to access XML files stored on another server via my ASP.NET 2.0 Web Application. I've tried the UNC path and even a mapped drive letter. I know this isn't a coding issue but security issue. Do I need to install IIS on the other server and setup the ASP user account to have access? Brent

    ASP.NET csharp asp-net sysadmin windows-admin security

  • SQL Server, Images and DataGrid in ASP.NET
    B bgates1970

    This is for ASP.NET 1.1 but should be easy to convert to 2.0. The stored proc inserts the file into a blob/image field in the table. Imports System Imports System.Configuration Imports System.Data Imports System.Data.SqlClient Public Class AttachmentDB Private Function FileFieldSelected(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As Boolean If FileField.PostedFile Is Nothing Then Return False If FileField.PostedFile.ContentLength = 0 Then Return False Return True End Function Private Function GetByteArrayFromFileField(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As Byte() ' Returns a byte array from the passed ' file field controls file Dim intFileLength As Integer, bytData() As Byte Dim objStream As System.IO.Stream If FileFieldSelected(FileField) Then intFileLength = FileField.PostedFile.ContentLength ReDim bytData(intFileLength) objStream = FileField.PostedFile.InputStream objStream.Read(bytData, 0, intFileLength) Return bytData End If End Function Private Function FileFieldType(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As String ' Returns the type of the posted file If Not FileField.PostedFile Is Nothing Then _ Return FileField.PostedFile.ContentType End Function Private Function FileFieldLength(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As Integer ' Returns the length of the posted file If Not FileField.PostedFile Is Nothing Then _ Return FileField.PostedFile.ContentLength End Function Private Function FileFieldFilename(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As String ' Returns the core filename of the posted file If Not FileField.PostedFile Is Nothing Then _ Return Replace(FileField.PostedFile.FileName, _ StrReverse(Mid(StrReverse(FileField.PostedFile.FileName), _ InStr(1, StrReverse(FileField.PostedFile.FileName), "\"))), "") End Function Public Function InsertAttachment(ByVal fileID As Int32, ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As Int32 If Not FileFieldSelected(FileField) Then Return -1 End If Dim myConnection As SqlConnection = New SqlConnection(sqlconnection) Dim myCommand As SqlCommand = New SqlCommand(

    ASP.NET database csharp asp-net sql-server com

  • WebClient Problems
    B bgates1970

    The file I'm trying to load is located on the server (Windows 2003 SP1). I have verified that the file that I "saved" is indeed the same file. bgates

    ASP.NET csharp sysadmin help

  • javascript coding for onmouseover event [modified]
    B bgates1970

    I haven't done anything particular with the onMouseOver but with the click event for a button. I'm guessing they may be similar. btn.Attributes.Add("onClick", "javascript:alert('TEST');");

    ASP.NET question csharp javascript asp-net

  • WebClient Problems
    B bgates1970

    I'm trying to open a server side MS-Word document and present it client side. I just want the word document to appear inside the browser or open up for viewing. When I run the code I'm prompted to "Open" or "Save" the file. If I "Save" the file it is the file that I requested but if I "Open" I get the following error: "This file could not be found. Try one or more of the following: * Check the spelling of the name of the document. * Try a different file name." Code: Dim _webClient As New System.Net.WebClient Dim sURI aAs String = "file://C:\test.doc" Dim theBuffer As Byte() = _webClient.DownloadData(sURI) With Page.Response .ClearContent() .ContentType = "application/msword" .AddHeader("content-disposition", "attachement;filename=test.doc") .OutputStream.Write(theBuffer, 0, theBuffer.Length) .End End With _webClient.Dispose() bgates1970

    ASP.NET csharp sysadmin help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups