Friday, 23 August 2019

How to assign UpdatePanel Trigger's control ID with button's from gridview in asp.net

/////////////// Some  methods are below-

1. Using Gridview RowCreated Methode

protected void Gridview_RowCreated(object sender, GridViewRowEventArgs e)
    {
        LinkButton ControlID = (LinkButton)e.Row.Cells[0].FindControl("ControlID");
        if (ControlID != null)
        {
            ScriptManager.GetCurrent(this).RegisterPostBackControl(ControlID);
        }

    }



2. Using Gridview OnRowDataboud method

  protected void Gridview_Rowdatabound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            ImageButton ControlID = e.Row.FindControl("ControlID") as ImageButton;
            ScriptManager.GetCurrent(this).RegisterPostBackControl(ControlID);
        }

    }


3. Using For or Foreach loop


   private void Assign_PostBackControl(GridView Grd)
    {
        foreach (GridViewRow row in Grd.Rows)
        {
            LinkButton lnkFull = row.FindControl("ControlID") as LinkButton;
            ScriptManager.GetCurrent(this).RegisterPostBackControl(lnkFull);
        }
    }

Tuesday, 20 August 2019

The “&” character breaks Data that are stored in the web.config

//////////////// Inside the web.config file

Before


<appSettings>
<add key="Key" value="https://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}" />
  </appSettings>


After

<appSettings>

   <add key="Key" value="https://{s}.google.com/vt/lyrs=s&amp;x={x}&amp;y={y}&amp;z={z}" />  
  </appSettings>


How to access web.config settings directly in .aspx page?

///////////////////  In your web config file

<appSettings>
<add key="Key" value="this is test" />
</appSettings>



///////////////// In aspx file

<asp:TextBox ID = "txtBox1" runat = "server" Text="<%=System.Configuration.ConfigurationManager.AppSettings["Key"]%>" />


///////////////////////////// for the variable


<script type="text/javascript">
   $(document).ready(function () {
        var my1 = '<%=ConfigurationManager.AppSettings["Key"].ToString() %>';
               alert(my1);
     });
</script>

Tuesday, 13 August 2019

Could not load file or assembly. An attempt was made to load a program with an incorrect format (System.BadImageFormatException)



/////////////


1. You pretty sure,  you're having a 32-bit / 64-bit conflict. It sounds like your main project might be set to 32-bit while the class its referencing is set to 64-bit.

IIS >> Select Your Project >> check Application pools >> 
     IIS >> Application Polls >> Select Application pool of your project >> Advanced Setting >> Under general tab : Enable 32-bit applications -True

2. Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64

Thursday, 8 August 2019

Clear all forms controls from code-behind asp.net c#

/////////////

Use NameSpace

1. using System.Web.UI;
2. using System.Web.UI.HtmlControls;


public static void Clear_Controls_Comman(Panel ControlIDs)
    {
        foreach (Control item in ControlIDs.Controls)
        {
            if (item is TextBox)
            {
                TextBox t = item as TextBox;
                t.Text = "";
            }
            else if (item is CheckBox)
            {
                CheckBox t = item as CheckBox;
                t.Checked = false;
            }
            else if (item is DropDownList)
            {
                DropDownList t = item as DropDownList;
                t.ClearSelection();
                if (t.Items.Count > 0)
                {
                    t.SelectedIndex = 0;
                }
            }
            else if (item is CheckBoxList)
            {
                CheckBoxList t = item as CheckBoxList;
                t.ClearSelection();
            }
            else if (item is RadioButton)
            {
                RadioButton t = item as RadioButton;
                t.Checked = false;
            }
            else if (item is RadioButtonList)
            {
                RadioButtonList t = item as RadioButtonList;
                t.ClearSelection();
            }
            else if (item is HtmlInputText)
            {
                HtmlInputText t = item as HtmlInputText;
                t.Value = "";
            }
            else if (item is HtmlTextArea)
            {
                HtmlTextArea t = item as HtmlTextArea;
                t.InnerText = "";
            }
            else if (item is HtmlInputCheckBox)
            {
                HtmlInputCheckBox t = item as HtmlInputCheckBox;
                t.Checked = false;
            }

        }
    }

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...