Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys i Have Question How i Hide this textbox In edit template ? Back Code
ASP.NET
<HeaderTemplate>
                    ID<br />
                    <asp:TextBox ID="IDSrch" runat="server" OnTextChanged="IDSrch_TextChanged"></asp:TextBox>
                </HeaderTemplate>
Posted
Updated 3-Jan-16 20:28pm
v2
Comments
Herman<T>.Instance 4-Jan-16 3:58am    
Set ReadOnly="True" in TextBox tag

(from whatever I got from the one liner question)
Not sure about back code, but jQuery can help in great way. Hide text box from client side using jQuery.
Use specific check on client side to see if grid is in edit mode or set flag(hidden field etc) from back code to let client side know that the grid is editable. and hide textbox.

$('<%= IDSrch.ClientID %>').hide();


Or you can elaborate more about the situation if this doesn't help.
 
Share this answer
 
Comments
GTR0123 4-Jan-16 6:29am    
OnRowEditing << i have this event and if it is posible that i cann call this IDSrch << text box I give it Visible=False but How i can Call there this textbox?
basically when you use gridview textbox there is dynamic ID creation, and you can not hide particular textbox box, you need to either use client side scripting to hide textboxes or you need to run code behind code to hide entire column
 
Share this answer
 
Comments
Pravin.Bhosale01 5-Jan-16 7:59am    
Same thing I suggested above, GTR0123 is not able to make it working.
OnRowEditing event. Add this code to call javascript function from back code(Code behind)

ASP.NET
Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","HideTextBox()",true);


Now on your .aspx page, write below code block

Javascrpre
<script type="text/javascript">

function HideTextBox(){
$('#<%= IDSrch.ClientID %>').hide();
}

</script>

Make sure you put javascript code on .aspx page(not in any .js file). hope this will solve your problem.
 
Share this answer
 
v2
Comments
GTR0123 4-Jan-16 7:13am    
On Javascript code It can't See IDsrch
Pravin.Bhosale01 4-Jan-16 7:40am    
make sure ID of control is correct. If problem still persist. Use css class name to control.

cssClass='txtHideThis'
So your text box code will look like
<asp:TextBox ID="IDSrch" runat="server" OnTextChanged="IDSrch_TextChanged" cssClass="txtHideThis">

and change javascript code to below.
$('.txtHideThis').hide();
GTR0123 5-Jan-16 3:03am    
it isn't working it isn't doing anything i check everything but not working MBy becouse this textbox is in Gridview in HeadeR?
Pravin.Bhosale01 5-Jan-16 8:01am    
have you tried executing $('.txtHideThis').hide(); from browser's console, Please check if any JS error.
Also, make sure if you are using ID to access textbox in JQuery code you are using $('#<%= IDSrch.ClientID %>').hide();

And if you are using cssClass use $('.txtHideThis').hide();
in .cs file write this, you can fill value, but can't edit

IDSrch.enabled=false;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900