rowmark
asked on
OnClientClick not getting fired
Hello Experts,
I have this button and a dropdownbox:
<asp:DropDownList ID="ddlLookupType" AutoPostBack=true CausesValidation=false OnSelectedIndexChanged="sh owPickList " runat=server>
<asp:ListItem>Contacts</as p:ListItem >
<asp:ListItem>Organization </asp:List Item>
</asp:DropDownList>
<asp:Button id="btnSearch" runat="server" Text="Search" />
and on load of the page I am adding the OnClientClick attribute as shown below:
if (ddlLookupType.SelectedVal ue == "Organization")
{
btnSearch.Attributes.Add(" OnClientCl ick", "openOrganizationPopup(); return false;");
}
else
{
btnSearch.Attributes.Add(" OnClientCl ick", "openContactPopup(); return false;");
}
But it is not getting fired. If I specify in the html code instead of code behind it works fine. Whats the mistake I am doing.
Please help
Thanks
I have this button and a dropdownbox:
<asp:DropDownList ID="ddlLookupType" AutoPostBack=true CausesValidation=false OnSelectedIndexChanged="sh
<asp:ListItem>Contacts</as
<asp:ListItem>Organization
</asp:DropDownList>
<asp:Button id="btnSearch" runat="server" Text="Search" />
and on load of the page I am adding the OnClientClick attribute as shown below:
if (ddlLookupType.SelectedVal
{
btnSearch.Attributes.Add("
}
else
{
btnSearch.Attributes.Add("
}
But it is not getting fired. If I specify in the html code instead of code behind it works fine. Whats the mistake I am doing.
Please help
Thanks
ASKER
I want to call diff javascript method based on the value from the dropdown thats why I cant specify in the <asp:button tag itself.
if (ddlLookupType.SelectedVal ue == "Organization")
{
btnSearch.Attributes.Add(" OnClientCl ick", "openOrganizationPopup(); return false;");
}
else
{
btnSearch.Attributes.Add(" OnClientCl ick", "openContactPopup(); return false;");
}
if (ddlLookupType.SelectedVal
{
btnSearch.Attributes.Add("
}
else
{
btnSearch.Attributes.Add("
}
openPopup(ddlLookupType.Se lectedValu e);
and then handle it in the JS?
is that possible? off the top of my head - haven't got time to test atm
and then handle it in the JS?
is that possible? off the top of my head - haven't got time to test atm
ASKER
no this doesnt work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks John it worked.
Isn't onClientClick for confirmation messages and the like returning some info from the server?
If you want to carry our a client side function why not just put onClick='openContactPopup(