.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

getting text from local .txt file to Textbox.

Posted By:      Posted Date: October 10, 2010    Points: 0   Category :ASP.Net

Ok, So I've read that its impossible to get the client computer name (If your website is in a different server) I've tried it all but all (I guess) I got was the Router Computer name.

my project is for INTRANET use...

so.. I tried cheating.. please guide me here.

What I want to do is store the computername of the workstation in a textfile and import it in a textbox so I can later on insert it in a database.

Here's my code

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim FILE_NAME As String = "file:///C:/test.txt"
        Dim objReader As New System.IO.StreamReader(FILE_NAME)
        TextBox1.Text = TextBox1.Text & objReader.ReadToEnd

    End Sub

Will My idea work at all?

View Complete Post

More Related Resource Links

Trying to launch a .exe file on my local computer from intranet site.


I have been told I can launch a local program on my PC from my intranet site but it has to be done with Active X or vbscript and not javascript.  I found the following little sample html code that will launch notepad.  However, I cannot figure out how to put this in a button, etc., within my aspx or code behind to execute it.  Does anybody have any idea how to do this?  I have a lot of javascript code I am launching urls with and I have even tried using that but again, I have been told that to do it client side it needs to be vbscript or something like this.  Any ideas?

  <title>Web page that runs EXE files</title>
  <h1>Web page that runs EXE files</h1>
  <p>Click <a href="file:///C:/windows/notepad.exe" class="navbar">here</a>
  to run notepad.exe (Windows XP, ME, 98, 95)</p>
  <p>Click <a href="file:///C:/winnt/notepad.exe" class="navbar">here</a>
  to run notepad.exe (Windows 2000, NT)</p>


Writing to a text file



I have the following  subroutine in an asp.net application class. The subroutine writes data to a text file upon application login.   My question is that if this function was called at the same time by two different  users would it cause any kind of error. Is there a need for a try catch?

 Public Shared Sub writeToLogFile(ByVal UserName  As String)
        Dim strLogMessage As String = String.Empty
        Dim strLogFile As String = System.Web.HttpContext.Current.Server.MapPath("~/Log.txt") Dim swLog As StreamWriter
        strLogMessage = DateTime.Now.ToShortDateString().ToString()  " ==> " & UserName

        If Not File.Exists(strLogFile) Then
            swLog = New StreamWriter(strLogFile)
            swLog = File.AppendText(strLogFile)
        End If


Textbox text populated by Session Variable wont update into SQL with new text


Hi everyone, I have what I think is a weird issue. I send text from one page to another via Session Variable. When page 2 loads, the text box has the session text set, but if the user changes the text and clicks the button, the SQL database is update with the original session text. If I remove the redirect from the page 2 button_Click method, then, the page refreshes with the textbox reverting to the session text and thr SQLDataSource has the session text added to it.

Why would the button click cause the textbox refresh with the text from the pageLoad before updating the data source?


Partial Class _1
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Session("UpdateProd") = "Have some text here to send to a textbox on page 2"
    End Sub
End Class

Partial Class _2
    Inherits System.Web.UI.Page


The file reached the maximum download limit. Check that the full text of the document can be meaning



I'm facing an issue with the indexing.

I have 1 WFE+Index server+DB server.

Index server is not installed with MS FIlter pack 1.0

When crawling, the there will be document with warning in crawl log:
The file reached the maximum download limit. Check that the full text of the document can be meaningfully crawled.

Documents that with warning are such as doc, ppt, xls, docs, ppts and many others.
However, I view into the successful crawled document, there are doucments with ext doc and ppt.

For large file index, there are MaxGrowthFactor + MaxDownLoadSize required to be added into the index server.

As my understanding is, MS Filter Pack should installed into index server(already did, correct me if i'm wrong).

I looked into the Office SharePoint Seach(CA>Services in farm), if the server is appointed to "Use this server as indexing server", then MS Filter Pack is suppose to be installed into that particular server as well.

At the bottom, there also has another option is "Use all web front end for crawling".

The question here is, IF the option "Use all web front end for crawling" is selected.
Does the WED FRONT END Server required to installed the Ms Filte

Update Profile Database from text file using BDC



I have a requirement to import the profile properties from a text file in sFTP to update the MOSS Profile Database. The objective is to create a single repository for the Staff Directory in MOSS.

Can I use BDC to connect and update the Profile database?

What is the alternate approach?


Deleting Last Line of Text in a text file

Hi, I needed some help on the best way to delete the last line of  text in a text file. I have a subroutine that looks like this, but it is missing some code. Could anyone advise me on this? Dim strLogFile As String = System.Web.HttpContext.Current.Server.MapPath("~/Log.txt")         Dim fs As New FileStream(strLogFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None)         Dim swLog As New StreamReader(fs)         Dim array As String()         Dim value As String = swLog.ReadToEnd ''Array that holds the lines of the text file.         array = value.Split(vbCrLf)        ''code for deleting last line: . . .  fs.Close()

Replace Text in textbox in word document using interop and asp.net

Hi all,  I'm trying to create a function to replace fields in a word document using asp.net. The fields are marked in the document using ###field### and I need to replace them with the data from the DB. The code I have works fine for the body of the word document but doesn't appear to work if the text is contained within a textbox, is there a way to correct this? Here's the code I am currently using Dim Contract as string Dim word As New Word.Application        Dim doc As Word.Document        Try            word.Documents.Open("c:\FYI.doc")            word.Visible = True             doc = word.ActiveDocument            Dim myStoryRange As Microsoft.Office.Interop.Word.Range            For Each myStoryRange In doc.StoryRanges                With myStoryRange.Find                    .Text = "###field###&quo

TextBox shows binding source text when window load, so why not with the ComboBox?

How can I get a ComboBox to show the binding source value when my window opens?  I have been searching all day for a solution to this, but cannot find anything.  So I have created a sample project to demonstrate my problem.  Below is a Vehicle class, very simple, two members Category and Make.  Category is an enumeration, Make is a string. namespace ComboExample { public class Vehicle { // Constants and enumerations public enum eCategory { Road, Air, Sea } // Attributes public eCategory Category { get; set; } public String Make { get; set; } // Construction public Vehicle(eCategory Category, String strMake) { this.Category = Category; this.Make = strMake; } } } Here is the C# for the MainWindow.  A new Vehicle object is created as a member.  In the constructor I set a data-provider in the XAML to this Vehicle object.  There is a button event for showing the values of the controls and objects so I can check the binding. namespace ComboExample { // Interaction logic for MainWindow.xaml public partial class MainWindow : Window { // Attributes Vehicle m_Car = new Vehicle(Vehicle.eCategory.Road, "BMW"); // Construction public MainWindow() { InitializeComponent(); // link data-p

Data loading from text file

Hi, I am loading the data from a flat file into a sql table. The values in one of the column have spaces at the end of the value. I want to remove those spaces and load into the table. I am thinking of using derived column and use rtrim on that column, how can I use that as an expression. Thanks.sqldev

Consistently running out of page file memory with full text indexer

Using MS SQL Server 2008 SP1 x64 Standard Edtion on Windows 2008 R2 Enterprise, I'm about to full-text index for the first time 1 table and 2 views. The table contains about 250'000 entries with a data space of 180 MB. As soon as I activate the full text indexing, the fdhost.exe task starts to consume slowly but surely all the available page file space (this can be easily watched using the Resource Monitor and the Commit Charge graph on the memory tab). Once all the virtual memory has been consumed, the server becomes unusable since it can't open any new windows any more, and RDP stops working. The machine specs are as follows: 12 GB of RAM 80 GB free on hard disk out of 136 GB 8 CPUs Custom size paging file with sizes between 24 GB - 60 GB (originally, this was system managed size, but then the server ran out of memory sooner) Max SQL server memory set to 6 GB (first 10 GB, then 8 GB) I've set the max fulltext crawl range to 8. During the indexing, the 8 CPUs are bit busy for a while, but not excessively. What is astonishing is that there is almost no use of physical memory during the indexing (I can see an increase from 2 GB to 3 GB which still leaves plenty of RAM available). Does anybody have an idea how I can convince fdhost.exe to consume physical memory and leave the paging memory alone? Or what else can I try?

Read a text file on another server from a web page

How do I read/write a text file on another server from a web page. I get the error "Access to the path '//Server2/mydatafiles/test.txt' is denied". I do not get the error if I am running the browser on the server where the files exist. I think I need to set permissions on the destination server in some way.   Can you help? Thanks  

Highlight text in a textbox

I have a textbox that could be 100 chars long. If I know the start & end positions of the text to highlight (via start & end position textboxes), how can I just highlight that portion of the characters in the textbox? 

convert xml file as text file using xml document

hi i want to convert to xml file to text file using xml document.. M not much aware of xml..so please guide me.... my boss told me don use xmltextreader and using xml document convert to txt file.....  

How to put text from an external text file into a text box on a report.

Hi all, We're moving from our legacy reporting app to SQL Server Reporting Services 2008 and I'm converting our reports slowly but surely.  In our organization, one of our departments sends out letters that have standard marketing messages and disclaimers that they put into .rtf files.  Currently, our reporting application has an RTF box control that can do that fairly easily.  I've not found a similar control in SSRS 2008.  My thought, then, was to use a piece of embedded code in the report to grab the necessary text from the file and reference it in the Value of a Placeholder (using a Code.<FunctionName>.ToString() statement) - using HTML tags for the necessary formatting for those files. I don't care if I have to convert the existing RTF files to HTML files to do this, that's not an issue.  The code I'd come up with is this:  Public Function GetTextFile(ByVal strFileName as String) As String Dim oFile as System.IO.File Dim oRead as System.IO.StreamReader oRead = oFile.OpenText(strFileName) GetTextFile = oRead.ReadToEnd() End Function And the Expression I was using to get the text from the file is:  =Code.GetTextFile("HTMLTest.txt").ToString() Where "HTMLTest.txt" is the file name that I'm using.  The text itself is just a line of text with some HTML tags included for formatting - bold, color,

Saving SSIS results to Log or text file using dtexec

Hi, How to save the SSIS package results to log file using dtexec command............please help regaridng this...........   Thanks in advance,

Textbox in headertemplate gridview lost text in updatepanel

Hi everybody,I never post on this forum because since I write code in asp.net I always solve issues by finding solutions with other members who have the problem before me. But this time I don't know how to do...This is my problem : I have a gridview inside an updatepanel and i modified some headers in order to filter the collection. This worked but when my updatepanel is updating, my textbox for the filter clear the value (the text) and lost focus.Is there any solution ?This is my code : <asp:UpdatePanel ID="UpdatePanelOrders" runat="server" UpdateMode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger ControlID="btFilterClear" /> </Triggers> <ContentTemplate> <asp:GridView ID="OrdersView" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" ShowHeaderWhenEmpty="True" EnablePersistedSelection="True" PagerStyle-CssClass="pager" AlternatingRowStyle-CssClass="alter_row" SelectedRowStyle-CssClass="select_row" DataKeyNames="CustId,SalesOrders,CompCode,CustPO"> <Columns>

When I click on a TextBox the text moves a little bit for Vertical Alignment

I have a Grid of text boxes defined in the XAML using the following code:         <Border Grid.Row="2" Grid.Column="11" Style="{StaticResource BorderStyleContent}" >             <TextBox Text="-15.11" Style="{StaticResource EditableTextBox}"/>         </Border> The styles are defined below:         <Style x:Key="BorderStyleContent" TargetType="Border">             <Setter Property="BorderBrush" Value="Black"/>             <Setter Property="BorderThickness" Value="1"/>             <Setter Property="Padding" Value="2"/>             <Setter Property="SnapsToDevicePixels" Value="True"/>         </Style>         <Style x:Key="EditableTextBox" TargetType="TextBox">         &nb
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend