Posts

Random Password Generator in C#.NET

Image
This blog is going to illustrate the Random Password Generator in the .NET Framework. The GeneratePassword method is used to generate a random password and is most commonly used for reset password and new or temporary password. It is a very easy to use method. GeneratePassword() method will generate the password with specific length. The following is a syntax for GeneratePassword method public   static   string   GeneratePassword  ( int   length ,  int   numberOfNonAlphanumericCharacters ); Length (int): The password length numberOfNonAlphanumericCharacters (int): Minimum no. of alphanumeric characters. The following is a code snippet to generate a random password. Here length and nonAlphaNumeric values are passed to Membership.GeneratePassword() method. And the result has been assigned to the password textbox. using   System . Web . Security ;   private   void   GeneratePasswordButton_Click ( object   send...

Take Screenshot and Download with Blazor WebAssembly

Image
This blog will show you how to take a screenshot with Blazor WebAssembly. There is currently no way to take a screenshot in Blazor. So, in this blog, I'll use the Javascript library html2canvas to capture and download the screenshot. The code below is an index.razor code. In the source code. To use Javascript functions, IJSRuntime is injected. To collect the message, I've added a textbox. This message will be captured in the screenshot. Two new buttons have been added. The first is to take a screenshot, and the second is to download the screenshot. Two methods for taking and downloading screenshots have been added to the @code area. The Javascript methods Takeshot and DownloadImg do not return any values, So I use the InvokeVoidAsync method to call them. index.razor @page   "/" @inject   IJSRuntime   jsRuntime   < h3 > Take Screenshot with Blazor WebAssembly </ h3 >   < div   id = "screenshotContainer" ...

Dynamically Create and Delete Elements in Blazor

Image
This blog is going to explain how to create and delete elements in Blazor. Let's see step by step Step 1: Create Dynamic Element The code for creating dynamic elements is shown below. I created a class named Movie with the fields Name, ReleasedYear, and CoProduction. Inside the for loop, three textboxes were added to collect movie information. I also included a button to generate a new row of text boxes. @page   "/" < h4 > Dynamic Elements </ h4 > < style >      body  {          font-size :  12px ;     }        table  {          width :  50%   !important ;     } </ style >   < table   class = "table" >      < thead >          < tr >              < th > Movie Name </ th > ...

Templated Component with RenderFragment in Blazor

Image
What RenderFragment is and how to use it in an application will be covered in this blog. The component and content are rendered with the aid of the RenderFragment. Reusing the components is made easier by the templated component. RenderFragment and RenderFragment<T> are the two different sorts of render elements. RenderFragment - It is a just a simple razor content RenderFragment<T> - It allows parameters within the razor content. The context keyword helps to set a parameter within the razor content. Let's start by looking at a simple RenderFragment example. The code for the child component is as follows. In this case, ChildContent is declared as RenderFragment. The UI segment is rendered by this RenderFragment. additionally, the @ChildContent is put within the <div> element. Child.razor < h3 >Child</ h3 > < div   class = "alert alert-primary" >      @ ChildContent </ div > @ code   {   ...