Thursday, July 6, 2023

Change Display of an Javascript RadioButton using ASP.net C#

 ASP.net Page:

Pickup location: <input runat="server" id="inRadHome" checked type="radio" name="inRadioPickup" value="Home" />Home  


Behind c# page :

if(condition)

{

 string script_clinic = "<script type='text/javascript'>document.getElementById('inRadHome').value = 'Clinic'; document.getElementById('inRadHome').nextSibling.nodeValue = 'Clinic'; </script>";

        ClientScript.RegisterStartupScript(this.GetType(), "ChangeInputValue", script_clinic);

}

Tuesday, June 20, 2023

Use DropDownList in EditTemplate in GridView

 Instead using a TextBox in the EditTemplate of a GridView, if needed you can use a DropdownList , here is a code in HTML page  :

<EditItemTemplate>                        

         <asp:DropDownList ID="type_edit" runat="server" AutoPostBack="true" SelectedValue='<%# Bind("transaction_type") %>' >

                    <asp:ListItem Value="" ></asp:ListItem>

                    <asp:ListItem Value="LOAN">LOAN</asp:ListItem>

                    <asp:ListItem Value="PRINCIPAL PAYMENT">PRINCIPAL PAYMENT</asp:ListItem>

                    <asp:ListItem Value="INTEREST PAYMENT">INTEREST PAYMENT</asp:ListItem>

             </asp:DropDownList>

  </EditItemTemplate>


You do not have to write anything in code behind page.😀😀