I am doing show and hide of server controls i.e Textboxe and DropDownList using jquery.
Show and hide is working fine but the element which is hidden is taking up its blank space on the page .
I've tried following tricks to hide the elements after using jquery hide() function:
css('visibility', 'hidden')
css('display', 'none')
as defined in this Question
But still the same problem .
Here is my code:
<script>
$(document).on("click", ".edit", function () {
var col_name= $(this).data('col_name');
var tbl_name = $(this).data('tbl_name');
var tr = $(this).parent().parent();
var tdRecords = $(tr).children();
var CurrValue = $(tdRecords[0]).text();
$('#<%= txt_Curr_Val.ClientID %>').val(CurrValue);
$('#<%=txt_colname.ClientID%>').val(col_name);
$('#<%=txt_tblname.ClientID%>').val(tbl_name);
if (col_name == 'relig_code')
{
$('#<%=ddl_relig.ClientID%>').show('slow');
//$('#<%=txt_New_Val.ClientID%>').hide('slow');
$('#<%=txt_New_Val.ClientID%>').css('visibility', 'hidden')
}
else
{
//$('#<%=ddl_relig.ClientID%>').hide('slow');
$('#<%=ddl_relig.ClientID%>').css('visibility', 'hidden')
$('#<%=txt_New_Val.ClientID%>').show('slow')
}
});
</script>
Here is the HTML :
<div class="modal-body">
<div class="row">
<div class="col-md-3">
Current Value :
</div>
<div class="col-md-8">
<asp:TextBox CssClass="txtstyle txtwidth" runat="server" ID="txt_Curr_Val" TextMode="MultiLine"></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-md-3">
New Value :
</div>
<div class="col-md-8">
<asp:TextBox CssClass="txtstyle txtwidth" runat="server" ID="txt_New_Val" TextMode="MultiLine"></asp:TextBox><br />
<asp:DropDownList runat="server" ID="ddl_relig"></asp:DropDownList><br />
<asp:TextBox CssClass="txtstyle" runat="server" ID="txt_tblname" ></asp:TextBox><br />
<asp:TextBox CssClass="txtstyle" runat="server" ID="txt_colname"></asp:TextBox>
</div>
</div>
</div>
After trying display : none
its look like :
How can I resolve this ?
Thanks for your Help