how to stop refreshing of current page when any server side event of web user control being fired

StackOverflow https://stackoverflow.com/questions/17610837

I'm building a web user control. Now i need to fire some server side events on web user control. And also need to stop page refreshing. Can any one tell me how can i fire server side event on web user control without refreshing hole page.

Edit-1

My control (.ascx)

<%--Control designer start--%>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
    <div style="position:relative;border:none;" id="divComboContainer" runat="server" >
        <%--Hidden fields for datacombo values--%>
        <asp:HiddenField ID="Hidden_Value" Value="" runat="server" />
        <asp:HiddenField ID="Hidden_SorDir" Value="" runat="server" />
        <asp:HiddenField ID="Hidden_RowIndex" Value="" runat="server" />
        <asp:HiddenField ID="hfScrollPosition" Value="" runat="server" />

        <%--Seleted text display textbox--%>
        <asp:TextBox ID="txtDisplay" runat="server" CssClass="tb10" autocomplete="off" ToolTip="Type for search"></asp:TextBox>

        <%--Panal and controls for dropdown--%>
        <asp:Panel ID="DropPanel" runat="server" CssClass="ContextMenuPanel" Width="1000px"
            style="display :none; 
                visibility: hidden;
                border:2px solid #E5E5E5;
                padding-bottom:-1px;
                margin-top:-28px;
                background-color:#83ACF3;
                overflow:hidden;
                height:auto;
                max-height:700px;
                max-width:1000px;">
            <%--<asp:Button ID="Button1" runat="server" Text="Button" />--%>
            <%--Search textbox div--%>
            <div class="ddeSerch">
                <div style="padding-top:5px;float:left;">
                    &nbsp;&nbsp;Look-Up&nbsp;
                </div>
                <asp:TextBox runat="server" ID="txtSearch" autocomplete="off" CssClass="tb10" BackColor="White" Width="50%" MaxLength="150"
                    onclick="return false;"
                    style="background: url(GridViewCSSThemes/Images/tia.png) no-repeat top right;background-color:White;padding-right:25px;">
                </asp:TextBox>
                <div style="padding-top:5px;float:right;cursor:pointer;" runat="server" id="dcmbClose" >
                    Close
                </div>
            </div>

            <%--Datacombo header--%>
            <asp:Table ID="Table1" runat="server" CssClass="header" GridLines="Vertical" Width="100%">
            </asp:Table>
            <%--Datacombo body(records)--%>
            <div id="divGrid" runat="server" style="max-height:615px;width:100%;overflow-X:auto;overflow-Y:auto;">
                <asp:GridView ID="gridEdit" GridLines="Vertical" runat="server" Width="100%" 
                    ShowFooter="false" AutoGenerateColumns="false" ShowHeader="false" AllowSorting="true"
                    Font-Size = "11pt" Font-Names = "Arial"  style="color:Black;"
                    AlternatingRowStyle-BackColor="#CCDDFB" 
                    RowStyle-BackColor="WhiteSmoke" 
                    OnRowCreated="gridEdit_RowCreated" OnRowDataBound="gridEdit_RowDataBound" OnSorting="gridEdit_Sorting">
                    <HeaderStyle HorizontalAlign="Left" CssClass="header" Font-Bold="false" />
                    <RowStyle CssClass="rowstyle"/>
                    <Columns>
                    </Columns>
                </asp:GridView>
            </div>

            <%--Datacombo footer--%>
            <table class="footer" id="tblfooter" runat="server">
                <tr>
                    <td style="text-align:left;">
                        <asp:TextBox Enabled="false" autocomplete="off" ID="lblOrd" CssClass="footer" runat="server" Width="100%"></asp:TextBox>
                    </td>
                    <td style="text-align:right;">
                        <asp:TextBox Enabled="false" autocomplete="off" ID="lblTot" CssClass="footer" style="text-align:right;" runat="server" Width="100%"></asp:TextBox>
                    </td>
                </tr>
            </table>
        </asp:Panel>
        <ajaxToolkit:DropDownExtender runat="server" ID="DDE"
            TargetControlID="txtDisplay" 
            DropDownControlID="DropPanel" HighlightBorderColor="Transparent">
        </ajaxToolkit:DropDownExtender>
    </div>
</ContentTemplate>
</asp:UpdatePanel>  

Use on aspx page

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <uc1:UCDataCombo runat="server" ID="UCDataCombo4"/>
        </ContentTemplate>
    </asp:UpdatePanel>

When user clicks on header of gridview it fires some events. And hole page got refreshed. I need to stop refreshing of hole page.

有帮助吗?

解决方案 2

Problem i solved by setting clientIDMode to Static.

clientIDMode="Static".

Now update panel works fine.

其他提示

UpdatePanel enables sections of a page to be partially rendered without a postback.

You can have a full understanding by reading here.

-EDIT-

I don't if this will help but you gotta try this:

Check if is set in your web.config, if it is there you may want to remove it.

Go to this link for more details.

Hope it helps!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top