Question

There is some code like this :

if ( bValid ) { 
      $( this ).dialog( "close" );
$("#btnExcel").show(); }

and .aspx look like :

  <form id="form1" runat="server">
                    <input id="inpHide" type="hidden" runat="server" />
                    <asp:Button ID="btnExcel" runat="server" Text="Excel" AccessKey="E" BorderWidth="0px"
                        OnClick="btnExcel_Click" ToolTip="Excel" Visible="false" />
                    </form>

`bValid` is some part of code

Why this doesnt work ? What can be done to work it out. To make button visisble ?

may be its not accessible because :

var button = $('#btnExcel')[0]; 
                        alert(button);

shows : undefined !

Looking for help.

Was it helpful?

Solution

You can't have the button as Visible="false" on the server side. That is in your ASPX page you need to have it Visible="true" because otherwise the button is not rendered to html.

You could set the style attirbute (or CssStyle attirbute) on your button to style="display:none;" and then things will work

<asp:Button ID="btnExcel" runat="server" Text="Excel" AccessKey="E" BorderWidth="0px"
                        OnClick="btnExcel_Click" ToolTip="Excel" Visible="true" style="display:none;" />

OTHER TIPS

Can you set the button's display to none?

Thats because the IDs of server controls generated by ASP.Net is different in the browser. View the HTML source in the browser, find the correct control ID and use that in the jQuery code. You can also try ClientID function of ASP.Net

See this for more: http://forums.asp.net/p/1522697/3664258.aspx

btnExcel will be mangled since its a server side control.

Obtain the mangled id as document.getElementByid(<%=btnExcel.ClientID%>)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top