justinpees justinpees - 1 month ago 6
ASP.NET (C#) Question

I have a textbox which I would like to allow my users to switch to a grid when they click a button. Is this possible in asp.net?

As of now I have a multiline textbox for my users. I would like my users to be able to switch the textbox into a grid layout when they click a button "Switch to Grid". How can I remove the textbox and make a grid layout appear in the same place when they click this button? If the user has already inputed something into the textbox/grid-layout, I'm okay with their inputs getting reset.

<asp:TextBox ID="txtvalue" ValidationGroup="g1" TextMode="MultiLine" runat="server" style="width:100%; max-width:100%; overflow-x:scroll; height:110px; white-space:nowrap; word-wrap:break-word;"></asp:TextBox>

Answer Source

You should put a grid right after your textbox and make the grid default hidden by css. Don't forget to assign an ID to the grid so you can easily grab it later using jQuery. Then when your user click on Switch to Grid button, all you have to do now is quite simple: first, make the textbox hidden and then make the grid appeared.

I've made a CodePen here