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.😀😀

Thursday, December 31, 2020

Transfer a textbox content of a popup window to a textbox of parent page


Transfer a textbox content of a popup window to a textbox of parent page

 <script type="text/javascript">      

    document.getElementById('Button2').onclick = function () {

        if (window.opener != null && !window.opener.closed) {

            var txtNew = window.opener.document.getElementById("TextBox1");

            txtNew.value = txtNew.value + "\n\n" + document.getElementById("TextBox_sms").value;

        } 

        window.close();

    }       

</script>


Monday, September 30, 2019

Check if string contains any matches in a string array


Check if string contains any matches in a string array

string med="TESTSTRIPS, LANCETS, ETOH SWABS #100";
string[] items = { "TESTSTRIPS", "GLUCOMET" };
 bool isneed_referal = items.Any(c => med.Contains(c));

Thursday, May 18, 2017

Convert a "YYYYMMDDHHMMSS" format string value to a DateTime value

string formatString = "yyyyMMddHHmmss";
string sample = "20100611221912";
DateTime dt = DateTime.ParseExact(sample,formatString,null);

Thursday, February 23, 2017

What does meta http-equiv=“X-UA-Compatible” content=“IE=edge” do?

 meta http-equiv="X-UA-Compatible" content="IE=edge"

If you are using the X-UA-Compatible META tag you want to place it as close to the top of the page's HEAD as possible. Internet Explorer begins interpreting markup using the latest version. When Internet Explorer encounters the X-UA-Compatible META tag it starts over using the designated version's engine. This is a performance hit because the browser must stop and restart analyzing the content.
Here are your options:
  • "IE=edge"
  • "IE=11"
  • "IE=EmulateIE11"
  • "IE=10"
  • "IE=EmulateIE10"
  • "IE=9"
  • "IE=EmulateIE9
  • "IE=8"
  • "IE=EmulateIE8"
  • "IE=7"
  • "IE=EmulateIE7"
  • "IE=5"
To attempt to understand what each means, here are definitions provided by Microsoft:
Internet Explorer supports a number of document compatibility modes that enable different features and can affect the way content is displayed:
  • Edge mode tells Internet Explorer to display content in the highest mode available. With Internet Explorer 9, this is equivalent to IE9 mode. If a future release of Internet Explorer supported a higher compatibility mode, pages set to edge mode would appear in the highest mode supported by that version. Those same pages would still appear in IE9 mode when viewed with Internet Explorer 9. Internet Explorer supports a number of document compatibility modes that enable different features and can affect the way content is displayed:
  • IE11 mode provides the highest support available for established and emerging industry standards, including the HTML5, CSS3 and others.
  • IE10 mode provides the highest support available for established and emerging industry standards, including the HTML5, CSS3 and others.
  • IE9 mode provides the highest support available for established and emerging industry standards, including the HTML5 (Working Draft), W3C Cascading Style Sheets Level 3 Specification (Working Draft), Scalable Vector Graphics (SVG) 1.0 Specification, and others. [Editor Note: IE 9 does not support CSS3 animations].
  • IE8 mode supports many established standards, including the W3C Cascading Style Sheets Level 2.1 Specification and the W3C Selectors API; it also provides limited support for the W3C Cascading Style Sheets Level 3 Specification (Working Draft) and other emerging standards.
  • IE7 mode renders content as if it were displayed in standards mode by Internet Explorer 7, whether or not the page contains a directive.
  • Emulate IE9 mode tells Internet Explorer to use the directive to determine how to render content. Standards mode directives are displayed in IE9 mode and quirks mode directives are displayed in IE5 mode. Unlike IE9 mode, Emulate IE9 mode respects the directive.
  • Emulate IE8 mode tells Internet Explorer to use the directive to determine how to render content. Standards mode directives are displayed in IE8 mode and quirks mode directives are displayed in IE5 mode. Unlike IE8 mode, Emulate IE8 mode respects the directive.
  • Emulate IE7 mode tells Internet Explorer to use the directive to determine how to render content. Standards mode directives are displayed in Internet Explorer 7 standards mode and quirks mode directives are displayed in IE5 mode. Unlike IE7 mode, Emulate IE7 mode respects the directive. For many web sites, this is the preferred compatibility mode.
  • IE5 mode renders content as if it were displayed in quirks mode by Internet Explorer 7, which is very similar to the way content was displayed in Microsoft Internet Explorer 5.