Tag Archives: Generate random number

Generate One Time Password (OTP) in Asp.net using C#

Aspx page code:- Enter Random Number length: <asp:TextBox ID=”txtno” runat=”server”/> <asp:Button ID=”btnGenerate” Text=”Random Number” runat=”server” onclick=”btnGenerate_Click” /><br /> <asp:Label ID=”lblResult” runat=”server” ForeColor=”Red” /> CS page code:- char[] charArr = “0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”.ToCharArray(); string strrandom = string.Empty; Random obj= new Random(); int noofcharacters = Convert.ToInt32(txtno.Text); for (int i = 0; i < noofcharacters; i++) { //It will not… Read More »