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

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

How to: textbox text should show only the last part of the string

Posted By:      Posted Date: September 17, 2010    Points: 0   Category :WPF
Hi, I have a textbox that shows info. (filename) When the filename is smaller than the width of the textbox all is fine, but when the filename is longer, i would like to show the last part of the filename in stead of the first part (default). Is this possible?

View Complete Post

More Related Resource Links

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


Need help with validating an alphanumeric string within a textbox control.

Hi everyone,I am developing a simple WinForms app for a presentation next week and need to validate that a particular string in a particular textbox is alphanumeric.  I have included the code from the button click event handler below: // Alphanumeric private void btnValidate4_Click(object sender, EventArgs e) { try { if (txtAlphanumeric.Text == "") MessageBox.Show("Please enter an alphanumeric string before clicking the 'Validate' button.", "Whoa there, pardner!!", MessageBoxButtons.OK, MessageBoxIcon.Information); else { Regex rgxAlphanumeric = new Regex("^[a-zA-Z0-9]*$"); Match alphaNumericMatch = rgxAlphanumeric.Match(txtAlphanumeric.Text); if (!alphaNumericMatch.Success) MessageBox.Show("The string supplied does NOT match the specified pattern.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); else { MessageBox.Show("The supplied string matches the specified pattern.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

How do I set a string in a textbox to unicode?

I have a report requirement to embed the fonts when the report is exported to PDF. The report server is  SSRS 2005 SP3 and upgrading to SSRS2008 is not an option. I have validated that all requirements have been met to ensure embedding have been met except one -  "The characters in the string that has the Font property set are Unicode, not ANSI. No font embedding occurs for ANSI characters." I referenced this article for requirements -  http://technet.microsoft.com/en-us/library/ms159713.aspx . My data is in a dataset field that was populated by a stored procedure. When I examine the rdl the it has a type name of System.String (<rd:TypeName>System.String</rd:TypeName>) How can I ensure that any strings in the report are recognized as unicode? The SSRS PDF renderer must be interpreting the strings as ANSI because that's how they are being rendered in the PDF file preventing embedding. Any assistance would be greatly appreciated!

How to read a column of a sharepoint list to a text string field of infopath form?

My infopath form used to read these email addresses from a web service and web.config file. Now i would like to get these user email addresses from a contact list in a sharepoint server. I am trying to do this without writing any codes. Here is what i have done so far: 1. Adding a new "data connection to receive data from SharePoint library or List" where i selected Email Address column of the contact list. 2. I added a new Text Field and define a new rule with "Query using a data connection" defined above. When i try to access the newly created Text field above it always return empty as if the Query attached to it did not executed at all. What did i do wrong? Is there a better way? Thank you in advance for your help.

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

Cleanest way of setting max string length for text in GridView cells?

I want to make sure that each row in the table is the height of one line of text only.  I know you can set RowStyle-Wrap="false", but I also don't want any really wide rows.  I know I can go through each cell on RowDataBound or something and cut it to a particular length and then append an ellipsis on the end, but is there a neater way of doing the same thing?

Cannot change value of pre-populated textbox in web part

I have a user control inside a web part. I am pre-populating a textbox in the Page_Load event in the code behind of the user control. The value I am pre-populating is a value the user previously entered. The value is pulled from a sharepoint list. We want the user to be able to change this value if they need to. No matter how many times I change the value in this field, it keeps the pre-populated value. It will not save the new value back to the list. The list item is being saved, but only with the pre-populated value. If I remove the line of code that pre-populates the textbox from the page_load event, then I can change the field without issue. Since I have little experience with using user controls, I am not sure what I am doing wrong. Should I be pre-populating this field in another event?  

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? 

Unable to Show Edit item Links in Data Form Web Part

I have a DFWP connected to custom list and the boxes to Show Edit Item Links, Show Delete item links and Show Insert Item links are grayed out so that they can not be checked. This works fine when I use a DFWP connected to a standard list (i.e., Contacts). Is there something special that needs to be done to activate this functionality?ThanksDean

C# .NET using a plain text string for a DESCryptoServiceProvider KEY and IV

Can someone please give me a solution to my problem below: I have this file encryption / decryption code which I found in the help docs... Well, all I want to do is use a custom 8 char password with the code... But I keep on getting this error: An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll Additional information: Specified key is not a valid size for this algorithm. What encoding should be used for the string to work? This line gives the error: DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey); Please help me with a solution: using System; using System.IO; using System.Security; using System.Security.Cryptography; using System.Runtime.InteropServices; using System.Text; namespace CSEncryptDecrypt { class Class1 { // Call this function to remove the key from memory after use for security [System.Runtime.InteropServices.DllImport("KERNEL32.DLL", EntryPoint = "RtlZeroMemory")] public static extern bool ZeroMemory(IntPtr Destination, int Length); // Function to Generate a 64 bits Key. static string GenerateKey() { // Create an instance of Symetric Algorithm. Key and IV is generated automatically. DESCryptoServiceProvider desCrypto = (DESCryptoServiceProvider)DESCryptoServiceProvider.Create(); // Use the Automatically generated key for Encryption. return ASCIIEncoding.ASCII.Get

Url String in textbox

how do i get my textbox to display my url string when the webbrowser has loaded a page. like in internet explorer? (wpf C#)

Passing String to Rdlc's TextBox

Hello  I am pretty new to reporting services. Now i have something like this. on the .cs file, i have a fullName lets say String fullName = "John Smith", Now I want to pass this string to the report's textBox and show this value on this textbox.   How can i do this? 1.How should i write in .cs file? 2. How should i set the expression for the textbox?   Thank you very much. It is very urgent! Please help!

Conversion from type 'TextBox' to type 'String' is not valid

I have a FormView that allows a user to register for a company event. I want to do a couple of things with this form. 1. I need to write this data to a MS SQL database 2. I need to send an email confirmation of their registration to their email. I know how to do both of these things, but i am having trouble doing both at the same time. It would be nice if I could do it in one click, but I coded it into two pages to try to help simplify it. The first page allows the user to input their information into a formview and when they click the submit button, it places those answers into session variables:Protected Sub InsertButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Session("FirstName") = Me.FormView1.FindControl("FirstName") Session("LastName") = Me.FormView1.FindControl("LastName")  <li> <label> First Name</label> <asp:TextBox ID="FirstName" runat="server" class="text-box" Text='<%# Bind("FirstName") %>' /> </li> </ul> </div>

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>

show value in label on textbox change event

I want to show value in label on textbox change event , means when user enter text in text box then this value should display in label  . I am using this:<asp:UpdatePanel ID="UpdatePanel1" runat="server">    <ContentTemplate>     <asp:TextBox ID="TextBox5" runat="server" ontextchanged="TextBox5_TextChanged" AutoPostBack="true"></asp:TextBox>    </ContentTemplate>    </asp:UpdatePanel>========================================================protected void TextBox5_TextChanged(object sender, EventArgs e)     {         ViewState["xyz"] = Convert.ToInt32(TextBox4.Text) - Convert.ToInt32(TextBox5.Text);         ViewState["xyz1"] = Convert.ToInt32(ViewState["xyz"].ToString()) * 100;         lbldiff.Text = ViewState["xyz"].ToString();         lblprofit.Text = ViewState["xyz1"].ToString();     }protected void TextBox5_TextChanged(object sender, EventArgs e)    {        ViewState["xyz"] = Convert.ToInt32(TextBox4.Text) - Convert.ToInt32(TextBox5.Text);        ViewState["xyz1

Content Query Web Part (CQWP) fails to show picture items from a document/picture library in an anon

I have a Picture Library and am trying to use the CQWP to display a list of items in the library.  The web part shows the items fine in authenticated mode, but it fails to show the items to anonymous users. The error log message is: Error while executing web part: System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.SetDocumentIconUrlAndOnClickString(SPWeb web, DataRow row, String strDefaultItemOpen, Boolean fSetDocIcon, Boolean fSetOnClick, String fileRefColumnRef, String progIdColumnRef, String fsobjTypeColumnRef, String permMaskColumnRef)     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.PreProcessForDocumentIconAndOnClickAttribute()     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.AddContentQueryData()     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.GetXPathNavigator(String viewPath)     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform(Boolean bDeferExecuteTransform) I'm running SP 2010.  I've tried various scenarios including: 1. Using the default publishing template. 2. Using the blank site template with publishing and lock down features enabled. 3. Us
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