开发者

In Chrome browser, Modal pop up pops up when clicking a button which is disabled

I have a page which has a modal pop up which shows on clicking a link button. I have disabled the link button but on clicking the disabled link button also the modal pop up appears. It works fine in all other browsers except Chrome. How to prevent modal pop up from being shown when the link button(target control) is disabled?

The code is given below:

 <cc1:ModalPopupExtender ID="ModalPopupExtender" runat="server" BackgroundCssClass="modalBackground"
            CancelControlID="imgbtnCancel" DropShadow="true" PopupControlID="panelTenant"
            TargetControlID="lnkbtnTenant">
        </cc1:ModalPopupExtender>
        <asp:Panel ID="panelTenant" CssClass="modalPopup" Style="display: none" Width="400px"
            runat="server">
        <asp:Button ID="btnTest" Text="Test" runat="server"></asp:Button>
        </asp:Panel>

In page_load event of the code, I have checked a condition and disabled the link button when the condition fails.

if (ds.Tables[3].Rows.Count > 0)
            {
                lnkbtnTenant.Enabled = true;
                lnkbtnTenant.Text = "Click to view Tenant Details";               
            }
            else
            {
                lnkbtnTenant.Enabled = false;
                lnkbtnTenant.Text = "Tenant Details not available.";                
            }


Edited to include the generated-html, posted by OP in the comments:

This is the resulting HTML of the modal pop up:

<div id="ctl00_head_panelTenant" class="modalPopup" style="width:400px;display: none">
     <input type="submit" name="ctl00$head$btnTest" value="Test" id="ctl00_head_btnTest"/>
</div>

This is the resulting HTML of the disabled button:

<a id="ctl00_head_lnkbtnTenant" disabled="开发者_StackOverflow中文版disabled" class="para1">Tenant Details not available.</a>


It looks like ASP.NET puts a disabled="disabled" attribute onto the anchor, which is not valid HTML. Chrome ignores this non-standard attribute, hence you can still click on the link.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜