I am trying to build an login page, but when I tried adding a bit of C# code to change a eye icon from closed to open. It's for showing the password. The problem is that I think my C# code is not getting called.
@page "/"<form> <div class="head-container"><label class="head-label" >Login</label><div class="username-container"><label class="username-label" >Username</label><input type="text" class="username-input" /></div><div class="password-container"><label class="password-label" >Password</label><div class="passwordInp-container" ><input type="password" class="password-input" id="password-input" /><!-- This is the Image im trying to change --><img src="@imageURL" class="password-eye" @onclick="ShowPassword" id="eye"/></div></div><input type="submit" value="Submit" class="submit-button" /><p class="newUserPassword"><a href="" class="aTag">Register</a></p></div></form> @code { public string imageURL = "/media/eye-closed.ico"; public void ShowPassword() { Console.WriteLine("ShowPassword method called"); if (imageURL == "/media/eye-closed.ico") { imageURL = "/media/eye-open.ico"; } else { imageURL = "/media/eye-closed.ico"; } }}Thanks for any help in advance!
I tried to to include a Console.WriteLine() in the function but even that wouldnt show. But the imageURL variable is being set to the desired path, so the code is running, just not the function.