Exequielcitus
New Member
I have one web control (called \[code\]A\[/code\]) and one web page (Called \[code\]Default\[/code\]). Is there a way to call a JavaScript function from \[code\]Default\[/code\] that belongs to \[code\]A\[/code\] instead of using \[code\]OnClientClick\[/code\]? I am using the following in \[code\]Page_Load\[/code\] of \[code\]Default.aspx.cs\[/code\] (This is where my JavaScript function is coming from): \[code\]a = (A)LoadControl("~/A.ascx");a.ID = "AgControl";panel.Controls.Add(a);\[/code\]In Default.aspx I have the following: \[code\]<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_OnClick"OnClientClick="JavaScript()" />\[/code\]DefaultPage.aspx.cs:\[code\]protected void Button1_OnClick(object sender, EventArgs e) { String a = getValueofA(); If (a == "1") { //OnClientClick code goes here } else If (a == "2") { //No OnClientClick code goes here } }\[/code\]My goal is to remove \[code\]OnClientClick="JavaScript()\[/code\] and code it only in the first part of the "if statement".