Hi there
I have a alphanumeric id for customers. But i want to able to change the characters by providing textbox to use my clients own defined characters.
I want to generate a lets say a supplier ID as ARS001...and so on. This can be done by using code in vb.net and sql server queries. What i want is I want to give a textbox option in the application for the enduser so that they can change the first characters "ARS" to any other whatever they want to use and at the same time I want to limit those characters to 3 or 4 like "ARS" or "ARSH" and then followed by numbers upto 5 digits.
Please help me
thanks
Download FREE API for Word, Excel and PDF in ASP.Net:
Download
Hi arsh.whd,
Will you please explain your requirement in more details. If possible to explain with example.
Hi there
I want to generate a lets say a supplier ID as ARS001...and so on. This can be done by using code in vb.net and sql server queries. What i want is I want to give a textbox option in the application for the enduser so that they can change the first characters "ARS" to any other whatever they want to use and at the same time I want to limit those characters to 3 or 4 like "ARS" or "ARSH" and then followed by numbers upto 5 digits.
thanks
mukesh1
on Apr 09, 2018 01:32 AM
on Apr 09, 2018 01:56 AM
3
if want to show value according to u, but don;t want to change in databse. then
Texbox1.Text="ABC"+ur_database_value;
or if want to change in database also, then u need to one extra column in databse to store that value.
Hi arsh.whd,
Check this example. Now please take its reference and correct your code.
HTML
<asp:TextBox runat="server" ID="txtCharacters" />
<asp:Button Text="Get Supplier Id" runat="server" OnClick="Generate" />
<br />
<asp:Label ID="lblSupplierId" runat="server" />
C#
protected void Generate(object sender, EventArgs e)
{
int value = 1;
string code = txtCharacters.Text.Trim();
string supplierId = "";
if (code.Length == 3)
{
supplierId = code + value.ToString().PadLeft(2, '0');
}
else if (code.Length == 4)
{
supplierId = code + value.ToString().PadLeft(1, '0');
}
lblSupplierId.Text = supplierId;
}
VB.Net
Protected Sub Generate(ByVal sender As Object, ByVal e As EventArgs)
Dim value As Integer = 1
Dim code As String = txtCharacters.Text.Trim()
Dim supplierId As String = ""
If code.Length = 3 Then
supplierId = code & value.ToString().PadLeft(2, "0"c)
ElseIf code.Length = 4 Then
supplierId = code & value.ToString().PadLeft(1, "0"c)
End If
lblSupplierId.Text = supplierId
End Sub
Screenshot
