Hiding a textbox In ASP.NET

P

psychomad

hi,

can someone help me?! I'm trying to hide a textbox in my ASP.Net
source code, but it's not working!

This is part of the HTML code that i want to be hidden!


<tr>
<td style="width: 170px">
Product Number:</td>
<td style="width: 214px"><asp:textbox id="txtProduct_Number"
runat="server" Width="215px" /> </td>
</tr>


What should i do to Hide the Textbox??????
 
P

psychomad

<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb"%>


<script language="VB" runat=server>
Dim oConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.
4.0;Data Source=C:\bhavish_vb_asign\StoresDbs.mdb")
Dim strProduct_Number as string



Sub Insert_Click(ByVal Src As Object, ByVal E As EventArgs)
Dim oDA As OleDbDataAdapter
Dim oDS As New DataSet
Dim sSql As String
oConn.Open()


oDA = New OleDbDataAdapter(sSql, oConn)
oDA.Fill(oDS, "product")
txtProduct_Number.Text =
oDS.Tables("product").Rows(0).Item("Product_Number")



End Sub



Private Function update(ByVal oConn As OleDbConnection, ByVal
strInsertSQL As String) As Integer
Dim intQueryState As Integer
' Connect to Database
oConn.Open()
'Make the OleDbCommand object
Dim cmdInsert As New OleDbCommand(strInsertSQL, oConn)
intQueryState = cmdInsert.ExecuteNonQuery()
oConn.Close()
Return intQueryState
End Function

Private Function Exists(ByVal oConn As OleDbConnection, ByVal
Value As String, ByVal ValueColumn As String, ByVal Item As String,
ByVal ItemColumn As String, ByVal TableName As String, Optional ByVal
bIsNumeric As Boolean = False) As Integer
Dim blnUserAuthenticated As Boolean = False
' Connect to Database
Dim strSQL As String = "Select * from " & TableName & "
where " & ItemColumn & "='" & Item & "' AND " & ValueColumn & "=" &
IIf(bIsNumeric, Value, "'" & Value & "'")
Dim cmd As New OleDbCommand(strSQL, oConn)
Dim objDataReader As OleDbDataReader
objDataReader = cmd.ExecuteReader()
oConn.Close()



End Function

</script>

<html>

<title> EDITING PRODUCTS</title>

<body background="pale.jpg" bgproperties="fixed">

<form runat=server>




<h3><font face="Verdana" color="blue">EDIT PRODUCTS </font></h3>
<font color="blue" face="Verdana"><span style="font-
family: Times New Roman"><span
style="color: #cc0000">Enter Product Name and
Details for Update </span>
</span></font>
<br />
<br />
<table style="font-family: Times New Roman">

<tr>
<td style="width: 170px">
Product Number:</td>
<td style="width: 214px"><asp:textbox id="txtProduct_Number"
runat="server" Width="215px" /> </td>
</tr>


</table>
<asp:button text="Update Products" OnClick="Insert_Click"
runat=server/>
<p>
<asp:Label id="Msg" ForeColor="red" Font-Name="Verdana" Font-
Size="10" runat=server />

</form>
</body>
</html>
 
R

Riki

psychomad said:
hi,

can someone help me?! I'm trying to hide a textbox in my ASP.Net
source code, but it's not working!

This is part of the HTML code that i want to be hidden!


<tr>
<td style="width: 170px">
Product Number:</td>
<td style="width: 214px"><asp:textbox id="txtProduct_Number"
runat="server" Width="215px" /> </td>
</tr>


What should i do to Hide the Textbox??????

txtProduct_Number.Visible=false
 
M

Mark Rae

Well, as far as I can see, the code you posted refers to txtProduct_Number
twice:
txtProduct_Number.Text =
oDS.Tables("product").Rows(0).Item("Product_Number")
and

<td style="width: 214px"><asp:textbox id="txtProduct_Number"
runat="server" Width="215px" /> </td>

I can't see any code in which you are trying to hide the TextBox...
 
M

Mark Rae

txtProduct_Number.Visible=false

That won't hide the textbox - it will actually stop it from even being
rendered and sent down to the client browser, which is not the same thing...
 
P

psychomad

txtProduct_Number.Visible=false

This doesn't work...in fact the right code is

txtProduct_Number.Visible ="false"

but this doesn't work also!


The field Product_Number in my database is set to 'AUTO NUMBER'
and i dnt want it to be displayed when the page is running. The page
is meant for UPDATE of the Product and i don't want the administrator
to be able to change the product number as the Row must only be
Updated not Inserted!!!!
 
M

Mark Rae

txtProduct_Number.Visible=false

This doesn't work...in fact the right code is

txtProduct_Number.Visible ="false"

No it isn't. The Visible property of webcontrols accepts boolean values, not
string values...
but this doesn't work also!
The field Product_Number in my database is set to 'AUTO NUMBER'
and i dnt want it to be displayed when the page is running. The page
is meant for UPDATE of the Product and i don't want the administrator
to be able to change the product number as the Row must only be
Updated not Inserted!!!!

So post the code where you are actually trying to hide this TextBox - you
still haven't done that...
 
P

psychomad

the prob is that i don't know where to put the invisiblity of the
textbox Dear!!!!! I dnt kno if i must put it in th Sub or the 1st
Function or the 2nd Funcyion or the HTML code !!!!!
 
J

Juan T. Llibre

Display the product number in an <asp: Label...>, not in a textbox,
if you don't want it to be editable.
 
D

David

You could have set the text box to visible = false. Whilst it doesn't render
it, the content is still in the viewstate (if viewstate is still enabled for
the box). When the page posts back, you can still read its value, even
though it was not displayed.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


Display the product number in an <asp: Label...>, not in a textbox,
if you don't want it to be editable.

"psychomad" <[email protected]>
wrote in message









- Show quoted text -



THANKS dear... That was the idea !!!!! It was so easy yet i didnt
thought about it !!!!!
 
J

Juan T. Llibre

re:
!>THANKS dear... That was the idea !!!!!

You're quite welcome.

re:
!> It was so easy yet i didnt thought about it !!!!!

Sometimes the simplest things trip us.
It takes somebody else to see what eludes us.

Been there, done that! :)





Display the product number in an <asp: Label...>, not in a textbox,
if you don't want it to be editable.

Juan T. Llibre, asp.net MVP
====================


THANKS dear... That was the idea !!!!! It was so easy yet i didnt
thought about it !!!!!
 
M

Mark Rae

the prob is that i don't know where to put the invisiblity of the
textbox

Put it anywhere you like - it hardly matters...

"><asp:textbox id="txtProduct_Number"
runat="server" Width="215px" />

txtProduct_Number.Visible = False

or

asp:textbox id="txtProduct_Number" runat="server" Width="215px"
Visible="false" />
Dear!!!!!

Dear...?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,531
Members
45,004
Latest member
KetoBoostGummies

Latest Threads

Top