Sunday 11 September 2016

Set UserControl Value On click of Button Present in another UserControl

Inline image 1Inline image 2


Write Below Code in UserControl1 

<%@ Reference VirtualPath="~/Control2.ascx" %>


On Button Click

 Control2 ctrlA = (Control2)Page.FindControl("Control_2");//Control_2 is the tagName that is used for Control2 in the aspx Page
 TextBox ddl = (TextBox)ctrlA.FindControl("txtResult");
//txtResult is the Textbox id Present in Control2
 ddl.Text = txtusername.Text;

Thursday 14 August 2014

Call OnChange along with selectedindexchanged in dropdownlist

<script type="text/javascript">
    function Validate(Uid)
    {      
        document.getElementById('<%=TBPwd1.ClientID%>').value = '';
        document.getElementById('<%=TBPwd2.ClientID%>').value = '';
        eval('__doPostBack("'+Uid+'", "");');
        return false;
    }
</script>


<asp:DropDownList ID="DropDownListLevel" runat="server" AutoPostBack="True"  Width="250px" onchange="return Validate(this.name);"  onselectedindexchanged="DropDownListLevel_SelectedIndexChanged">
    </asp:DropDownList>


protected void DropDownListLevel_SelectedIndexChanged(object sender, EventArgs e)
{
}