views:

283

answers:

3

I used server-side code to hide a div, but when I click the button tool for another event the div is always open. I'm using ASP.net C# code.

Boss below is my code... i use chekbox for control the div... but when i click button for server side code this div is open plz solve the problem

****<div id="ChargeInvSlab"  style="display:inline; width:100%; border:1px solid Gray" >
<table >
<tr>
    <td>
        <dxe:ASPxLabel ID="ASPxLabel3" runat="server" Text="Amount From" Width="100px">
        </dxe:ASPxLabel>


        </td>
    <td >
        <dxe:ASPxTextBox ID="ASPxTxtboxAmountInvestor" runat="server" Width="170px" 
            ClientInstanceName="ASPxTxtboxAmountInvestor" MaxLength="13">
            <ValidationSettings SetFocusOnError="True">

                    </ValidationSettings>
                    <ClientSideEvents KeyUp="function(s, e) {ConvertNumberToWordInvestor12(s,e); }" />
             <ClientSideEvents KeyPress="function(s, e) {CheckAmount(event);
}" />       
        </dxe:ASPxTextBox>
    </td>
    <td >
        <dxe:ASPxLabel ID="ASPxLabel7" runat="server" Text="Amount To" Width="100px">
        </dxe:ASPxLabel>
        </td>
    <td >
        <dxe:ASPxTextBox ID="ASPxtxtAmounttoInvestor" runat="server" Width="170px" 
            ClientInstanceName="ASPxtxtAmounttoInvestor" MaxLength="13" >
            <ValidationSettings SetFocusOnError="True">

                    </ValidationSettings>
                    <ClientSideEvents KeyUp="function(s, e) {ConvertNumberToWordInvestor12(s,e); }"  />
                     <ClientSideEvents KeyPress="function(s, e) {CheckAmount(event);
}" />  
        </dxe:ASPxTextBox>
    </td>

</tr>
<tr>
    <td >
        <dxe:ASPxLabel ID="ASPxLabel4" runat="server" Text="Charge Rate" Width="100px">
        </dxe:ASPxLabel>
        </td>
    <td >
    <dxe:ASPxTextBox ID="ASPxTxtChargeRateSlabInvestor" runat="server" Width="170px" 
            ClientInstanceName="ASPxTxtChargeRateSlabInvestor" MaxLength="5">
            <ValidationSettings SetFocusOnError="True">

                    </ValidationSettings>
                    <ClientSideEvents KeyUp="function(s, e) {ConvertNumberToWordInvestor12(s,e); }"  />
                    <ClientSideEvents KeyPress="function(s, e) {CheckAmount(event);
}" />  
        </dxe:ASPxTextBox>
    </td>

    <td >
    <dxe:ASPxLabel ID="ASPxLabel9" runat="server" Text="Minimum Charge " Width="100px">
    </dxe:ASPxLabel>
    </td>
    <td >
    <dxe:ASPxTextBox ID="ASPxTxtMinimumCharge_slabInvestor" runat="server" Width="170px" 
            MaxLength="13" ClientInstanceName="ASPxTxtMinimumCharge_slabInvestor">
     <ValidationSettings SetFocusOnError="True">

                    </ValidationSettings>
                    <ClientSideEvents KeyUp="function(s, e) {ConvertNumberToWordInvestor12(s,e); }"  />
                     <ClientSideEvents KeyPress="function(s, e) {CheckAmount(event);
}" />  
        </dxe:ASPxTextBox>
    </td>
</tr>
<tr>

<td >

        </td>
    <td >

    </td>

<td >
        <dxe:ASPxButton ID="ASPxButtonAdd" runat="server" 
            Text="ADD" onclick="ASPxButtonAdd_Click">
        </dxe:ASPxButton>
        </td>
    <td >
        <dxe:ASPxButton ID="ASPxButtonClear" runat="server" Text="Clear" 
            onclick="ASPxButtonClear_Click">
        </dxe:ASPxButton>
    </td>
</tr>
<tr>
 <td colspan="4">
   <dxwgv:ASPxGridView ID="ASPxGridViewAddInvestor" runat="server" 
        AutoGenerateColumns="False" 
        ClientInstanceName="ASPxGridViewAddInvestor" EnableCallBacks="False" Width="400px" 
         DataSourceID="CslaDataSourceAddGreed" KeyFieldName="SlabSerialNo">
        <SettingsBehavior AllowFocusedRow="True" />
        <SettingsText EmptyDataRow="EmptyDataRow = 'No Data Exists'" />
        <ClientSideEvents FocusedRowChanged="function(s, e) {LoadViewAllDataInvestor();}" />
        <TotalSummary>
            <dxwgv:ASPxSummaryItem FieldName="Slab_Serial_No" ShowInColumn="SlabSerialNo" SummaryType="Count" />

        </TotalSummary>
        <Columns>
            <dxwgv:GridViewDataTextColumn FieldName="ClientCompanyId" Visible="False" 
                VisibleIndex="0">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="ProductId" Visible="False" 
                VisibleIndex="0">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="InvestorAccountId" Visible="False" 
                VisibleIndex="1">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="ChargeId" Visible="False" 
                VisibleIndex="0">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="SlabSerialNo" Visible="False" 
                VisibleIndex="2">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="SlabAmountFrom" VisibleIndex="0">
                <PropertiesTextEdit DisplayFormatString="{0:n2}">
                </PropertiesTextEdit>
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="SlabAmountTo" VisibleIndex="1">
                <PropertiesTextEdit DisplayFormatString="{0:n2}">
                </PropertiesTextEdit>
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="SlabChargeRate" VisibleIndex="2">
                <PropertiesTextEdit DisplayFormatString="{0:n2}">
                </PropertiesTextEdit>
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="RecordStatus" Visible="False" 
                VisibleIndex="5">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="MakerId" Visible="False" 
                VisibleIndex="5">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="CheckerId" Visible="False" 
                VisibleIndex="5">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="AuthorizerId" Visible="False" 
                VisibleIndex="5">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="RecordActionType" Visible="False" 
                VisibleIndex="5">
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="MinimumChargeAmount" VisibleIndex="3">
                <PropertiesTextEdit DisplayFormatString="{0:n2}">
                </PropertiesTextEdit>
            </dxwgv:GridViewDataTextColumn>
        </Columns>
        <Settings ShowFooter="True" />
    </dxwgv:ASPxGridView>
                 <dxhf:ASPxHiddenField ID="ASPxHiddenFieldSlabSerialnoInvestor" 
        runat="server" ClientInstanceName="ASPxHiddenFieldSlabSerialnoInvestor">
                    </dxhf:ASPxHiddenField>
    </td>
</tr>
</table>
</div>****
A: 

Make sure your div is marked with runat server and from your code set the display attribute to none to hide the div.

Thurein
A: 

Try using below code.

Make your div control server side and hide it using below code snippet.

divID.visible = false;

Or

divID.style.add("display","none");
GS_Guy
A: 

Your question is not clear at all.

My guess is, your hide/show logic is in Page Load, and your buttons are server buttons (which fire a postback), hence you're logic is getting overriden.

Sounds like you want to do this hidden logic in server code, in this case, why use a DIV? If your hide/show logic was in client-script (ie JavaScript), then yes - a DIV makes sense.

But given your doing it server side, use an ASP.NET PlaceHolder server control.

HTML:

<asp:PlaceHolder id="SomePlaceHolder" runat="Server" Visible="true">
   Some inner HTML
</asp:PlaceHolder>

Code-Behind:

SomePlaceHolder.Visible = false; // hide placeholder

Also depends on at what point do you want to hide this "DIV"? On load, on a button click, on postback, etc..

RPM1984