Saturday, March 31, 2012

TExt Box :-( image

Dear Advance,

How to save image from a given textbox text.

Regards,

Kamrul Hassan

huh?

You can't... if you want the client to upload an image use the upload control.... you can't pull a file off the client PC...thank heaven...

Text box

Hello can anybody write me how to clear text from texbox after I click on button

Hi

on Button's Click event (after you've read the Text) set

[VB]
TextBox1.Text = ""

[C#]
TextBox1.Text = "";

assuming your TextBox's ID isTextBox1


Use something like this in the click event handler of the button:

TextBox1.Text = "";

(where TextBox1 is the ID of your text box)

Regards,
Martin


This method: TextBox1.Text = ""; is not fast, because you make request on server ,optimal use JavaScript on ClientMachine:function f(){tbx.value="";}

Text Box

Hi,

I have an update button click event like this :

lblmessage.text = txtAuthor.text;

Even though I manually change the data in text box, somehow it does not show on to the label field.Whatever value I put in txtAuthor the label field is empty.

Any help is greatly appreciated. I hope I have framed my question properly.

With the semi-colon after the line, it looks like C#, so, just in case - what language are you using (VB or C#)?

augustwind:

With the semi-colon after the line, it looks like C#, so, just in case - what language are you using (VB or C#)?

I am using C#. Actually the updated data from the textbox goes to the property of an object. But when I found there was a problem I created a label control to see if the data is being read from the text box. But no data is being read from the text box.


Well - I don't really know what to tell you - it definitely should work.

Save it again - and rebuild - then run it, and put a break point at the code line and see if it ever hits that line.


Are u changing the value of the textbox in the page load, because that event is fired first.

Hope this helps

Thanks

Vikram

Vikram's Blog


Are you using Visual Web Developer? I have the same problem sometime when trying to get the values for update/.

Thanks


e_screw:

Are you using Visual Web Developer? I have the same problem sometime when trying to get the values for update/.

Thanks

I am using the Full blown edition of VS. I guess as Vikram suggested I am gonna have to check the code in the page load event.


Thanks a lot for the reply guys. I was able to fix the problem.

The problem was that I was pulling the data from the database in the page load event. And whenever I click the update button the original data from teh DB get loaded due to the page load event firing first. So there was no update taking place. Hence the label control which was pulling the data from the textbox was pulling the original data instead of the updated data... I hope I make sense in what I said.

I fixed it by adding the code for pulling data from the DB inside the " if (! IsPostBack) { } " block within the page load event. That fixed the problem in the test page that I created. I havent yet tested it on other pages that I am having trouble with. Hope fully I have resolved the problem. Thanks to Vikram for pointing out the Page Load event.

Text box

Could someone help me.

After hitting the submit page how do get the text box to clear? The
page is posting back to itself. What do I put on the code behind page?Just change the "EnableViewState" property of the Textbox to "False" in the
Properties Windows at design-time. No code necessary.

"JJ297" <nc297@.yahoo.comwrote in message
news:1193771080.275874.158090@.y42g2000hsy.googlegr oups.com...

Quote:

Originally Posted by

Could someone help me.
>
After hitting the submit page how do get the text box to clear? The
page is posting back to itself. What do I put on the code behind page?
>


"JJ297" <nc297@.yahoo.comwrote in message
news:1193771080.275874.158090@.y42g2000hsy.googlegr oups.com...

Quote:

Originally Posted by

After hitting the submit page how do get the text box to clear? The
page is posting back to itself.


The submit page...?

Quote:

Originally Posted by

What do I put on the code behind page?


What are you trying to do exactly...?

Please clarify precisely what you mean...

--
Mark Rae
ASP.NET MVP
http://www.markrae.net
IMO it won't work as persisting the texbox content is not done using
viewstate. By design field values are posted to a server (this is how an
HTML form works). The viewstate is there for any other property you could
have to maintain between postbacks except the textbox content).

Your best bet is to explicitelty set the value to an empty string in the
submit button event handler...

--
Patrice

"Scott M." <s-mar@.nospam.nospama crit dans le message de news:
udr8XiyGIHA.1184@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Just change the "EnableViewState" property of the Textbox to "False" in
the Properties Windows at design-time. No code necessary.
>
>
"JJ297" <nc297@.yahoo.comwrote in message
news:1193771080.275874.158090@.y42g2000hsy.googlegr oups.com...

Quote:

Originally Posted by

>Could someone help me.
>>
>After hitting the submit page how do get the text box to clear? The
>page is posting back to itself. What do I put on the code behind page?
>>


>
>


Just add this to your code:
MyTextBox.text=""

--

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup

"JJ297" <nc297@.yahoo.comwrote in message
news:1193771080.275874.158090@.y42g2000hsy.googlegr oups.com...

Quote:

Originally Posted by

Could someone help me.
>
After hitting the submit page how do get the text box to clear? The
page is posting back to itself. What do I put on the code behind page?
>


On Oct 30, 3:37 pm, "David Wier" <d...@.dw.comwrote:

Quote:

Originally Posted by

Just add this to your code:
MyTextBox.text=""
>
--
>
David Wierhttp://aspnet101.comhttp://iWritePro.com- One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
>
"JJ297" <nc...@.yahoo.comwrote in message
>
news:1193771080.275874.158090@.y42g2000hsy.googlegr oups.com...
>
>
>

Quote:

Originally Posted by

Could someone help me.


>

Quote:

Originally Posted by

After hitting the submit page how do get the text box to clear? The
page is posting back to itself. What do I put on the code behind page?- Hide quoted text -


>
- Show quoted text -


Thanks I added the text to my code and the box is now clear after
hitting the submit button.
On Oct 30, 3:37 pm, "David Wier" <d...@.dw.comwrote:

Quote:

Originally Posted by

Just add this to your code:
MyTextBox.text=""
>
--
>
David Wierhttp://aspnet101.comhttp://iWritePro.com- One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
>
"JJ297" <nc...@.yahoo.comwrote in message
>
news:1193771080.275874.158090@.y42g2000hsy.googlegr oups.com...
>
>
>

Quote:

Originally Posted by

Could someone help me.


>

Quote:

Originally Posted by

After hitting the submit page how do get the text box to clear? The
page is posting back to itself. What do I put on the code behind page?- Hide quoted text -


>
- Show quoted text -


Thanks it worked!

Text Box

I have a asp.net textbox on my page with a default value in it. I would like
the box to be cleared when some one clicks on the box.
How do I go about doing this?you need to add some client-side javascript like this:

onfocus=" if ( this.value == 'some default' ) this.value=''; " onblur="
if ( this.value == '' ) this.value = 'some default' ; "

Lou Civitella wrote:

Quote:

Originally Posted by

I have a asp.net textbox on my page with a default value in it. I would like
the box to be cleared when some one clicks on the box.
How do I go about doing this?

Text Box and Image Button

Hello,

I added a TextBox and an Image Button to a page so that they are side
by side.
Instead of both being top aligned the Text Box is pushed down.

Why is that?
How can I solve this?

Thanks,
MiguelHi there again,

<asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="Top" />
<asp:TextBox ID="TextBox2" runat="server" />

or

<table>
<tr>
<td valign="top">
<asp:ImageButton ID="ImageButton2" runat="server" />
</td>
<td valign="top">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
</table>

or

<div>
<div style="float:left">
<asp:ImageButton ID="ImageButton3" runat="server" />
</div>
<asp:TextBox ID="TextBox3" runat="server" />
</div>
--
Milosz

"shapper" wrote:

Quote:

Originally Posted by

Hello,
>
I added a TextBox and an Image Button to a page so that they are side
by side.
Instead of both being top aligned the Text Box is pushed down.
>
Why is that?
How can I solve this?
>
Thanks,
Miguel
>
>

Text Box and Image Button

Hello,
I added a TextBox and an Image Button to a page so that they are side
by side.
Instead of both being top aligned the Text Box is pushed down.
Why is that?
How can I solve this?
Thanks,
MiguelHi there again,
<asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="Top" />
<asp:TextBox ID="TextBox2" runat="server" />
or
<table>
<tr>
<td valign="top">
<asp:ImageButton ID="ImageButton2" runat="server" />
</td>
<td valign="top">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
</table>
or
<div>
<div style="float:left">
<asp:ImageButton ID="ImageButton3" runat="server" />
</div>
<asp:TextBox ID="TextBox3" runat="server" />
</div>
--
Milosz
"shapper" wrote:

> Hello,
> I added a TextBox and an Image Button to a page so that they are side
> by side.
> Instead of both being top aligned the Text Box is pushed down.
> Why is that?
> How can I solve this?
> Thanks,
> Miguel
>

Text box and Gridview on same page

How do I get the validation not to fire if I'm updating a gridview on
the page. When I try to update the item in the gridview the text box
won't allow me to update because of its validation set for that text
box. How do I get around this I need the validation on the text box
too. Here's my page.
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<center style="color: #006666">
<strong><span style="font-family: Arial; text-decoration:
underline">
Add a Topic</span></strong></center>
<center>
<asp:Label ID="Lbloutcome1" runat="server" ForeColor="Red"></
asp:Label> </center>
<center>
<asp:TextBox ID="TopicTxt" runat="server" TextMode="MultiLine"
Width="334px" EnableViewState="False" CausesValidation="True"></
asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="TopicTxt"
ErrorMessage="Enter a Topic">
*</asp:RequiredFieldValidator><br />
<asp:Label ID="LblMsg" runat="server"></asp:Label><br />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" /
>
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" />
<asp:Button ID="Button2" runat="server" Text="Reset"
CausesValidation="False" />
<br />
<br />
<asp:Label ID="Lbloutcome" runat="server" ForeColor="Red"
Width="237px"></asp:Label><br />
<asp:Label ID="Lbloutcome3" runat="server" ForeColor="Red"></
asp:Label><br />
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="classificationid"
DataSourceID="TopicsSqlDataSource"
AutoGenerateEditButton="True" BorderColor="#8E7953" BorderWidth="1px"
Width="209px" EnableViewState="False">
<Columns>
<asp:TemplateField HeaderText="Topic"
SortExpression="description">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("description") %>' Height="46px" Width="239px"></
asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<
%# Bind("description") %>'></asp:Label>
</ItemTemplate>
<ItemStyle BorderColor="#8E7953"
BorderStyle="Solid" />
<HeaderStyle BorderColor="#8E7953" Font-
Bold="True" Font-Size="Large" ForeColor="#006666" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete Topic"
InsertVisible="False" SortExpression="classificationid">
<ItemTemplate>
<asp:Label ID="classificationid"
runat="server" Font-Bold="True" Text='<%# DataBinder.Eval
(Container.DataItem, "classificationID") %>'
Visible="False"></asp:Label>
<asp:CheckBox ID="deleteRec" runat="server"
Font-Bold="True" />
</ItemTemplate>
<ItemStyle BorderColor="#8E7953" />
<HeaderStyle BorderColor="#8E7953" Font-
Bold="True" Font-Size="Large" ForeColor="#006666" />
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<br />
<asp:Button ID="Button3" runat="server" Text="Delete
Topic" CausesValidation="False" /><br />
<br />
<br />
<strong><span style="font-size: 14pt; color: #006666; font-
family: Arial; text-decoration: underline">
</span></strong>
<br />
<a href="http://links.10026.com/?link=AddTitle_Description.aspx" id="AddResourceAdminLink"
runat="server">Add a Resource</a><br />
<br />
<a href="http://links.10026.com/?link=EditResoureLibrary.aspx" id="EditResourceAdminLink"
runat="server">Edit Resource Library Information</a><br />
<br />
<br />
<table>
<tr>
<td style="width: 100px">
<a href="http://links.10026.com/?link=http://philanet/">
<img alt="PhilaNet" border="0" src="http://pics.10026.com/?src=Images/
philanet_small.gif" /></a></td>
<td style="width: 175px">
<a href="http://links.10026.com/?link=ResourceLibrary.aspx"><strong><span
style="font-size: 14pt">Resource Library</span></strong></a></td>
</tr>
</table>
<br />
<asp:SqlDataSource ID="TopicsSqlDataSource"
runat="server" ConnectionString="<%$
ConnectionStrings:TrainUserConnectionStr
ing %>"
SelectCommand="GetClassifications"
SelectCommandType="StoredProcedure" UpdateCommand="UpdateTopic"
UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="classificationID" Type="Int32" />
<asp:Parameter Name="description" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
</center>
</asp:Content>Checkout the ValidationGroup property.
"JJ297" <nc297@.yahoo.com> wrote in message
news:1194986781.386224.323330@.o3g2000hsb.googlegroups.com...
> How do I get the validation not to fire if I'm updating a gridview on
> the page. When I try to update the item in the gridview the text box
> won't allow me to update because of its validation set for that text
> box. How do I get around this I need the validation on the text box
> too. Here's my page.
> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
> Runat="Server">
> <center style="color: #006666">
> <strong><span style="font-family: Arial; text-decoration:
> underline">
> Add a Topic</span></strong></center>
> <center>
> <asp:Label ID="Lbloutcome1" runat="server" ForeColor="Red"></
> asp:Label> </center>
> <center>
> <asp:TextBox ID="TopicTxt" runat="server" TextMode="MultiLine"
> Width="334px" EnableViewState="False" CausesValidation="True"></
> asp:TextBox>
> <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
> runat="server" ControlToValidate="TopicTxt"
> ErrorMessage="Enter a Topic">
> *</asp:RequiredFieldValidator><br />
> <asp:Label ID="LblMsg" runat="server"></asp:Label><br />
> <asp:ValidationSummary ID="ValidationSummary1" runat="server" /
> <br />
> <asp:Button ID="Button1" runat="server" Text="Submit" />
> <asp:Button ID="Button2" runat="server" Text="Reset"
> CausesValidation="False" />
> <br />
> <br />
> <asp:Label ID="Lbloutcome" runat="server" ForeColor="Red"
> Width="237px"></asp:Label><br />
> <asp:Label ID="Lbloutcome3" runat="server" ForeColor="Red"></
> asp:Label><br />
> <asp:GridView ID="GridView1" runat="server"
> AutoGenerateColumns="False" DataKeyNames="classificationid"
> DataSourceID="TopicsSqlDataSource"
> AutoGenerateEditButton="True" BorderColor="#8E7953" BorderWidth="1px"
> Width="209px" EnableViewState="False">
> <Columns>
> <asp:TemplateField HeaderText="Topic"
> SortExpression="description">
> <EditItemTemplate>
> <asp:TextBox ID="TextBox1" runat="server"
> Text='<%# Bind("description") %>' Height="46px" Width="239px"></
> asp:TextBox>
> </EditItemTemplate>
> <ItemTemplate>
> <asp:Label ID="Label1" runat="server" Text='<
> %# Bind("description") %>'></asp:Label>
> </ItemTemplate>
> <ItemStyle BorderColor="#8E7953"
> BorderStyle="Solid" />
> <HeaderStyle BorderColor="#8E7953" Font-
> Bold="True" Font-Size="Large" ForeColor="#006666" />
> </asp:TemplateField>
> <asp:TemplateField HeaderText="Delete Topic"
> InsertVisible="False" SortExpression="classificationid">
> <ItemTemplate>
> <asp:Label ID="classificationid"
> runat="server" Font-Bold="True" Text='<%# DataBinder.Eval
> (Container.DataItem, "classificationID") %>'
> Visible="False"></asp:Label>
> <asp:CheckBox ID="deleteRec" runat="server"
> Font-Bold="True" />
> </ItemTemplate>
> <ItemStyle BorderColor="#8E7953" />
> <HeaderStyle BorderColor="#8E7953" Font-
> Bold="True" Font-Size="Large" ForeColor="#006666" />
> </asp:TemplateField>
> </Columns>
> </asp:GridView>
> <br />
> <br />
> <asp:Button ID="Button3" runat="server" Text="Delete
> Topic" CausesValidation="False" /><br />
> <br />
> <br />
> <strong><span style="font-size: 14pt; color: #006666; font-
> family: Arial; text-decoration: underline">
> </span></strong>
> <br />
> <a href="http://links.10026.com/?link=AddTitle_Description.aspx" id="AddResourceAdminLink"
> runat="server">Add a Resource</a><br />
> <br />
> <a href="http://links.10026.com/?link=EditResoureLibrary.aspx" id="EditResourceAdminLink"
> runat="server">Edit Resource Library Information</a><br />
> <br />
> <br />
> <table>
> <tr>
> <td style="width: 100px">
> <a href="http://links.10026.com/?link=http://philanet/">
> <img alt="PhilaNet" border="0" src="http://pics.10026.com/?src=Images/
> philanet_small.gif" /></a></td>
> <td style="width: 175px">
> <a href="http://links.10026.com/?link=ResourceLibrary.aspx"><strong><span
> style="font-size: 14pt">Resource Library</span></strong></a></td>
> </tr>
> </table>
> <br />
> <asp:SqlDataSource ID="TopicsSqlDataSource"
> runat="server" ConnectionString="<%$
> ConnectionStrings:TrainUserConnectionStr
ing %>"
> SelectCommand="GetClassifications"
> SelectCommandType="StoredProcedure" UpdateCommand="UpdateTopic"
> UpdateCommandType="StoredProcedure">
> <UpdateParameters>
> <asp:Parameter Name="classificationID" Type="Int32" />
> <asp:Parameter Name="description" Type="String" />
> </UpdateParameters>
> </asp:SqlDataSource>
> <br />
> </center>
> </asp:Content>
>
On Nov 13, 4:02 pm, "J055" <j...@.newsgroups.nospam> wrote:
> Checkout the ValidationGroup property.
> "JJ297" <nc...@.yahoo.com> wrote in message
> news:1194986781.386224.323330@.o3g2000hsb.googlegroups.com...
>
>
>
>
> - Show quoted text -
Thanks it worked!

Text Box and URL

it's not an asp issue, that's html
<body link=blue vlink=blue
and as for yout textbox/dropdown list question...It's unclear to me what you
are asking?

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"Hong" <anonymous@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:DC295FB3-91C8-44E3-B002-8CFA3C31AF6C@dotnet.itags.org.microsoft.com...
> Once I click on the url, it will change to purple color permanetly even i
stop the program and run it again. How to change the url color back to blue
color ?
> For text box, how to remove the dropdown list ??You can turn off autocomplete for the form or for individual text boxes.
See this article:

http://msdn.microsoft.com/workshop/...omplete_ovr.asp

-Jason

Curt_C [MVP] wrote:

> it's not an asp issue, that's html
> <body link=blue vlink=blue>
> and as for yout textbox/dropdown list question...It's unclear to me what you
> are asking?

Text Box and URL

Once I click on the url, it will change to purple color permanetly even i st
op the program and run it again. How to change the url color back to blue co
lor ?
For text box, how to remove the dropdown list 'it's not an asp issue, that's html
<body link=blue vlink=blue>
and as for yout textbox/dropdown list question...It's unclear to me what you
are asking?
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Hong" <anonymous@.discussions.microsoft.com> wrote in message
news:DC295FB3-91C8-44E3-B002-8CFA3C31AF6C@.microsoft.com...
> Once I click on the url, it will change to purple color permanetly even i
stop the program and run it again. How to change the url color back to blue
color ?
> For text box, how to remove the dropdown list '
You can turn off autocomplete for the form or for individual text boxes.
See this article:
http://msdn.microsoft.com/workshop/...omplete_ovr.asp
-Jason
Curt_C [MVP] wrote:

> it's not an asp issue, that's html
> <body link=blue vlink=blue>
> and as for yout textbox/dropdown list question...It's unclear to me what y
ou
> are asking?
>
Use a style or css to set the color of the A element.
Dale
"Hong" <anonymous@.discussions.microsoft.com> wrote in message
news:DC295FB3-91C8-44E3-B002-8CFA3C31AF6C@.microsoft.com...
> Once I click on the url, it will change to purple color permanetly even i
stop the program and run it again. How to change the url color back to blue
color ?
> For text box, how to remove the dropdown list '

Text Box and submit button not visible on the browser

Hi,
I am new to this group and to ASP.Net. I wrote a simple .aspx program in VS.Net environment. It has a label control, TextBox control and a button control. When the page is viewed on the browser, one enters their name or whatever and click the submit button, the resulting page shoul display "Hello and the text from the text box. I added required code in the button click event. The problem is when the page is loaded first time on the browser, I see only the label contol with the text that I entered before. Text Box and the Button controls are not visible. Any clues??
thanks.do you have runat=server for both?
Make sure that you have runat="server" in the html for the textbox and button...and make sure you have not set the visible property to false

MajorCats
I do have runat="server" and the Visible properties are set to False. Still it is not working. any other clues?...
After playing around with the code, I realized that none of my web controls are visible in the browser. If I change the following code
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
to
<input type="text" id="TextBox1"> </input>
then, I see the text box.
But it is not useful when I am trying to build a page using the web controls.
Why is it none of my web controls are visible?.
Anyone know what is triggering this kind of behavior?
help please...... :(
..."and the Visible properties are set to False."

I am assuming you meant that the visible property is NOT set to false...or this is your problem.

Post your html and code...

MajorCats
Here is the code... None of my web controls are visible when loaded in the browser. When I change them to a normal <input> tag, then it displays. It is not useful, when I am trying to develop a web application in the .Net environment. Text box property is set to Tru to begin with and then changed later in the code. see the button_click event handler code. Any help is appreciated.
thanks.

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = "Hello. " & TextBox1.Text & "!"
TextBox1.Visible = False
Button1.Visible = False
End Sub
End Class

<%@. Page Language="vb" AutoEventWireup="false" Codebehind="Hello.aspx.vb" Inherits="Aerosea.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<P>
<asp:Label id="Label1" runat="server">Enter a Name:</asp:Label>
<asp:TextBox id="TextBox1" runat="server" Visible="False"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="Submit" Visible="False"></asp:Button></P>
</form>
</body>
</HTML
Your problem is the visible=false in your tag...

<asp:TextBox id="TextBox1" runat="server" Visible="False"></asp:TextBox
Change this to:

<asp:TextBox id="TextBox1" runat="server" Visible="True"></asp:TextBox
and it will show up.

Basically, your code shows that you are hiding your textbox and button, and if the button were visible and someone clicked it, you are hiding it yet again......

MajorCats
Thank you very much. I totally overlooked the HTML part and thought the problem was in the Code. I changed it, and now it works.
thanks.

text box and SqlDecimal datatypes

Hi all, I have a DAL which takes in a value as shown below ready for my
MSSQL stored procedure.

protected SqlDecimal _annualLeave = SqlDecimal.Null;
public SqlDecimal AnnualLeave
{

get {return _annualLeave;}

set{ _annualLeave = value;}

}

I have a problem where when I try to pass in information from a textbox on a
ASP.NET page OR Winform the *damn* thing gets rounded to an Integer!

I thought I could just go..

((System.Data.SqlDecimal)AnnualLeave.Text)

Where AnnualLeave.Text is the value of my textbox on my form, but I received
"Cannot convert type 'string' to 'System.Data.SqlTypes.SqlDecimal" error
(Which is fair enough)

So, I tried

((System.Data.SqlDecimal)(Convert.ToDecimal(Annual Leave.Text))

but for some reason, this rounds the number to an integer!! e.g. 12.2
becomes 12!!!!!

Can someone please tell me what am I doing wrong here, it's been a long day
:P

Thanks
MarkHi Mark,

just use Convert.ToDecimal(AnnualLeave.Text)

HTH,

"Mark" <mark@.Z-Zvolution.nZt> wrote in message
news:OQXlCD24FHA.2364@.TK2MSFTNGP12.phx.gbl...
> Hi all, I have a DAL which takes in a value as shown below ready for my
> MSSQL stored procedure.
> protected SqlDecimal _annualLeave = SqlDecimal.Null;
> public SqlDecimal AnnualLeave
> {
> get {return _annualLeave;}
> set{ _annualLeave = value;}
> }
> I have a problem where when I try to pass in information from a textbox on
> a
> ASP.NET page OR Winform the *damn* thing gets rounded to an Integer!
> I thought I could just go..
> ((System.Data.SqlDecimal)AnnualLeave.Text)
> Where AnnualLeave.Text is the value of my textbox on my form, but I
> received
> "Cannot convert type 'string' to 'System.Data.SqlTypes.SqlDecimal" error
> (Which is fair enough)
> So, I tried
> ((System.Data.SqlDecimal)(Convert.ToDecimal(Annual Leave.Text))
> but for some reason, this rounds the number to an integer!! e.g. 12.2
> becomes 12!!!!!
> Can someone please tell me what am I doing wrong here, it's been a long
> day
> :P
> Thanks
> Mark
Hi Onin, I was actually doing this originally and still get the same
problem.

Thanks for your advice
Cheers
Mark
"Onin Tayson" <Leon_Tayson@.compaid.com> wrote in message
news:O%23qlxt44FHA.1140@.tk2msftngp13.phx.gbl...
> Hi Mark,
> just use Convert.ToDecimal(AnnualLeave.Text)
> HTH,
> "Mark" <mark@.Z-Zvolution.nZt> wrote in message
> news:OQXlCD24FHA.2364@.TK2MSFTNGP12.phx.gbl...
> > Hi all, I have a DAL which takes in a value as shown below ready for my
> > MSSQL stored procedure.
> > protected SqlDecimal _annualLeave = SqlDecimal.Null;
> > public SqlDecimal AnnualLeave
> > {
> > get {return _annualLeave;}
> > set{ _annualLeave = value;}
> > }
> > I have a problem where when I try to pass in information from a textbox
on
> > a
> > ASP.NET page OR Winform the *damn* thing gets rounded to an Integer!
> > I thought I could just go..
> > ((System.Data.SqlDecimal)AnnualLeave.Text)
> > Where AnnualLeave.Text is the value of my textbox on my form, but I
> > received
> > "Cannot convert type 'string' to 'System.Data.SqlTypes.SqlDecimal" error
> > (Which is fair enough)
> > So, I tried
> > ((System.Data.SqlDecimal)(Convert.ToDecimal(Annual Leave.Text))
> > but for some reason, this rounds the number to an integer!! e.g. 12.2
> > becomes 12!!!!!
> > Can someone please tell me what am I doing wrong here, it's been a long
> > day
> > :P
> > Thanks
> > Mark

text box and SqlDecimal datatypes

Hi all, I have a DAL which takes in a value as shown below ready for my
MSSQL stored procedure.
protected SqlDecimal _annualLeave = SqlDecimal.Null;
public SqlDecimal AnnualLeave
{
get {return _annualLeave;}
set{ _annualLeave = value;}
}
I have a problem where when I try to pass in information from a textbox on a
ASP.NET page OR Winform the *damn* thing gets rounded to an Integer!
I thought I could just go..
((System.Data.SqlDecimal)AnnualLeave.Text)
Where AnnualLeave.Text is the value of my textbox on my form, but I received
"Cannot convert type 'string' to 'System.Data.SqlTypes.SqlDecimal" error
(Which is fair enough)
So, I tried
((System.Data.SqlDecimal)(Convert.ToDecimal(AnnualLeave.Text))
but for some reason, this rounds the number to an integer!! e.g. 12.2
becomes 12!!!!!
Can someone please tell me what am I doing wrong here, it's been a long day
:P
Thanks
MarkHi Mark,
just use Convert.ToDecimal(AnnualLeave.Text)
HTH,
"Mark" <mark@.Z-Zvolution.nZt> wrote in message
news:OQXlCD24FHA.2364@.TK2MSFTNGP12.phx.gbl...
> Hi all, I have a DAL which takes in a value as shown below ready for my
> MSSQL stored procedure.
> protected SqlDecimal _annualLeave = SqlDecimal.Null;
> public SqlDecimal AnnualLeave
> {
> get {return _annualLeave;}
> set{ _annualLeave = value;}
> }
> I have a problem where when I try to pass in information from a textbox on
> a
> ASP.NET page OR Winform the *damn* thing gets rounded to an Integer!
> I thought I could just go..
> ((System.Data.SqlDecimal)AnnualLeave.Text)
> Where AnnualLeave.Text is the value of my textbox on my form, but I
> received
> "Cannot convert type 'string' to 'System.Data.SqlTypes.SqlDecimal" error
> (Which is fair enough)
> So, I tried
> ((System.Data.SqlDecimal)(Convert.ToDecimal(AnnualLeave.Text))
> but for some reason, this rounds the number to an integer!! e.g. 12.2
> becomes 12!!!!!
> Can someone please tell me what am I doing wrong here, it's been a long
> day
> :P
> Thanks
> Mark
>
Hi Onin, I was actually doing this originally and still get the same
problem.
Thanks for your advice
Cheers
Mark
"Onin Tayson" <Leon_Tayson@.compaid.com> wrote in message
news:O%23qlxt44FHA.1140@.tk2msftngp13.phx.gbl...
> Hi Mark,
> just use Convert.ToDecimal(AnnualLeave.Text)
> HTH,
> "Mark" <mark@.Z-Zvolution.nZt> wrote in message
> news:OQXlCD24FHA.2364@.TK2MSFTNGP12.phx.gbl...
on
>

Text Box Background Yellow at Runtime?

Folks,

I have a few text boxes that the backgrounds are set to white and appear white in the Visual Studio development widow. At runtime they appear as a brownish yellow.

What gives?

SethYou're viewing them on a Windows XP system.

Jeff
You might want to check this out:


Yellow textboxes

text box commands...i think

ok, so i have a textbox and 5 buttons, 4 list different things, and one is the search button...

no when i click enter, and i have text in my tetbox, the page loads, but doesnt do anything, yet when i click search the search function runs..

how do i make it so when a user hits enter on there text box, it runs that function...

Thanks, JustinPlace a simple html textbox in your form, make it hidden.

<input type="text" style="display: none;">

This way, pressing enter should submit the form.
but i dont use <form method="post" action="blabla">

Thanks, Justin
You have to have a form on your page if you're going to make the page work.

Text Box cocatenating instead of adding

When I run this line of code, I'm getting 444 instead of 12:
lblWkTotal1.text = lblSatTotal.text + lblSunTotal.text + lblMonTotal.text + lblTueTotal.text + lblWedTotal.text + lblThuTotal.text + lblFriTotal.text
If I run this line of code, I'm getting this error message: Cast from string "" to type 'Decimal' is not valid.
lblWkTotal1.text = CDec(lblSatTotal.text) + CDec(lblSunTotal.text) + CDec(lblMonTotal.text) + CDec(lblTueTotal.text) + CDec(lblWedTotal.text) + CDec(lblThuTotal.text) + CDec(lblFriTotal.text)
Any ideas how to correct the problem.
Thanks

Try changing from cDec to cDbl


Hi

Try usingCInt(TxtboxName.text).


Thanks David
When I change it to CDbl the followuing messages are generated:
[FormatException: Input string was not in a correct format.]
[InvalidCastException: Cast from string "" to type 'Double' is not valid.]
Any ideas where to go from here?
Franco

David
Changing to CDbl works OK if I first set the default text to 0.
Thanks for the suggestion.
Franco

Try forcing the result to a string
textBox.Text = CStr(Cint(blah) + CInt(Blah))
or
Dim i as Int32
i = CInt(Blah) + ...
textBox.Text = i.ToString()

Text Box Control MaxLenght Property Is Not Working

Hi All,

I have developed one web application.
In that I used aspnet web textBox control.
I have set maxlength property for that text box 300 and TextMode property as
multiline .

When i typed more than 3 or 4 line each line contains 30 to 40 characters,
If i clicked button for passing textbox value, that time my web page is not
responsding (no action taken).

The same page without refereshing if i delete some characters from my
textbox.
It is working.

Can someone help me for this?

--
Regards,
DhanaDhana,

What browser are you using?

"Dhana" <dhana@.celtycs-consulting.com> wrote in message
news:O4c8lqgDGHA.1028@.TK2MSFTNGP11.phx.gbl...
> Hi All,
> I have developed one web application.
> In that I used aspnet web textBox control.
> I have set maxlength property for that text box 300 and TextMode property
> as multiline .
> When i typed more than 3 or 4 line each line contains 30 to 40 characters,
> If i clicked button for passing textbox value, that time my web page is
> not responsding (no action taken).
> The same page without refereshing if i delete some characters from my
> textbox.
> It is working.
> Can someone help me for this?
> --
> Regards,
> Dhana
A TextBox in MultiLine mode is rendered as a TextArea HTML control. TextArea
as opposed to an Imput control does not have a maxlength property. It will
be ignored in the TextBox.

There are some 3rd party controls and projects out there that attempt to
control length with javascript for a multiline textbox. I haven't used any
of them so can't comment.

--

Andrew Robinson
www.binaryocean.com
www.bellinghamdotnet.org

"Dhana" <dhana@.celtycs-consulting.com> wrote in message
news:O4c8lqgDGHA.1028@.TK2MSFTNGP11.phx.gbl...
> Hi All,
> I have developed one web application.
> In that I used aspnet web textBox control.
> I have set maxlength property for that text box 300 and TextMode property
> as multiline .
> When i typed more than 3 or 4 line each line contains 30 to 40 characters,
> If i clicked button for passing textbox value, that time my web page is
> not responsding (no action taken).
> The same page without refereshing if i delete some characters from my
> textbox.
> It is working.
> Can someone help me for this?
> --
> Regards,
> Dhana
Ah yeah...

Try using a javscript function like:

function limitTextarea(textarea, maxlength) {
if (textarea.value.length > maxlength)
textarea.value = textarea.value.substring(0, maxlength);
}

and set the onchange attribute (either programatically with
textbox.attribute.add() or declaratively) on the textbox to call the
function.

"Andrew Robinson" <nemoby@.nospam.nospam> wrote in message
news:%23FQJ$5hDGHA.3820@.TK2MSFTNGP10.phx.gbl...
>A TextBox in MultiLine mode is rendered as a TextArea HTML control.
>TextArea as opposed to an Imput control does not have a maxlength property.
>It will be ignored in the TextBox.
> There are some 3rd party controls and projects out there that attempt to
> control length with javascript for a multiline textbox. I haven't used any
> of them so can't comment.
> --
> Andrew Robinson
> www.binaryocean.com
> www.bellinghamdotnet.org
>
> "Dhana" <dhana@.celtycs-consulting.com> wrote in message
> news:O4c8lqgDGHA.1028@.TK2MSFTNGP11.phx.gbl...
>>
>> Hi All,
>>
>> I have developed one web application.
>> In that I used aspnet web textBox control.
>> I have set maxlength property for that text box 300 and TextMode property
>> as multiline .
>>
>> When i typed more than 3 or 4 line each line contains 30 to 40
>> characters,
>> If i clicked button for passing textbox value, that time my web page is
>> not responsding (no action taken).
>>
>> The same page without refereshing if i delete some characters from my
>> textbox.
>> It is working.
>>
>> Can someone help me for this?
>>
>> --
>> Regards,
>> Dhana
>>
>>
>>

Text Box Control MaxLenght Property Is Not Working

Hi All,
I have developed one web application.
In that I used aspnet web textBox control.
I have set maxlength property for that text box 300 and TextMode property as
multiline .
When i typed more than 3 or 4 line each line contains 30 to 40 characters,
If i clicked button for passing textbox value, that time my web page is not
responsding (no action taken).
The same page without refereshing if i delete some characters from my
textbox.
It is working.
Can someone help me for this?
Regards,
DhanaDhana,
What browser are you using?
"Dhana" <dhana@.celtycs-consulting.com> wrote in message
news:O4c8lqgDGHA.1028@.TK2MSFTNGP11.phx.gbl...
> Hi All,
> I have developed one web application.
> In that I used aspnet web textBox control.
> I have set maxlength property for that text box 300 and TextMode property
> as multiline .
> When i typed more than 3 or 4 line each line contains 30 to 40 characters,
> If i clicked button for passing textbox value, that time my web page is
> not responsding (no action taken).
> The same page without refereshing if i delete some characters from my
> textbox.
> It is working.
> Can someone help me for this?
> --
> Regards,
> Dhana
>
>
A TextBox in MultiLine mode is rendered as a TextArea HTML control. TextArea
as opposed to an Imput control does not have a maxlength property. It will
be ignored in the TextBox.
There are some 3rd party controls and projects out there that attempt to
control length with javascript for a multiline textbox. I haven't used any
of them so can't comment.
Andrew Robinson
www.binaryocean.com
www.bellinghamdotnet.org
"Dhana" <dhana@.celtycs-consulting.com> wrote in message
news:O4c8lqgDGHA.1028@.TK2MSFTNGP11.phx.gbl...
> Hi All,
> I have developed one web application.
> In that I used aspnet web textBox control.
> I have set maxlength property for that text box 300 and TextMode property
> as multiline .
> When i typed more than 3 or 4 line each line contains 30 to 40 characters,
> If i clicked button for passing textbox value, that time my web page is
> not responsding (no action taken).
> The same page without refereshing if i delete some characters from my
> textbox.
> It is working.
> Can someone help me for this?
> --
> Regards,
> Dhana
>
>
Ah yeah...
Try using a javscript function like:
function limitTextarea(textarea, maxlength) {
if (textarea.value.length > maxlength)
textarea.value = textarea.value.substring(0, maxlength);
}
and set the onchange attribute (either programatically with
textbox.attribute.add() or declaratively) on the textbox to call the
function.
"Andrew Robinson" <nemoby@.nospam.nospam> wrote in message
news:%23FQJ$5hDGHA.3820@.TK2MSFTNGP10.phx.gbl...
>A TextBox in MultiLine mode is rendered as a TextArea HTML control.
>TextArea as opposed to an Imput control does not have a maxlength property.
>It will be ignored in the TextBox.
> There are some 3rd party controls and projects out there that attempt to
> control length with javascript for a multiline textbox. I haven't used any
> of them so can't comment.
> --
> Andrew Robinson
> www.binaryocean.com
> www.bellinghamdotnet.org
>
> "Dhana" <dhana@.celtycs-consulting.com> wrote in message
> news:O4c8lqgDGHA.1028@.TK2MSFTNGP11.phx.gbl...
>

text box cursor position on entry

Hi I want the cursor to align left when someone clicks in textbox.

textbox has maxlength of 7 when user clicks in text box

the cursor is at position 2 so they cant enter all 7 digits of number

without clicking home and reentering number.

It sounds to me like the textbox has some default text in it already. Otherwise, it would be at the left when they click in. Post your code so we can take a look.
As, suggested please check the Text property. By default when you click inside the TextBox is should align to the left at position "0".

add this in page_load...

sub page_load(byval sender as object, byval e as system.eventargs) handles page.load

txt1.text=""

end sub

cheers

moredotnet


thanks for the replies, I have put txtbox.text="" in page load will see what happens.

please use me.load instead of page.load

cheers

moredotnet


How I CAn Change the Cursor Color or Size InHTML TextBox

Thanks


Hi,

call a java script function onfocus, then set the value of text box to null and then call focus function on that control.

hope this would solve your problem


Unfortunately this not solve my problrm

When textbox.value=null ;

the textbox value be "null"


I wanna to write a dataSet as XML File

I use dataset.WriteXML("Filename"); Method

But if ther are an empty cell it will not Writen

Pls. Help Me;


Hi ,

I couldn't get you complete requirement. Can you try like this.

First check whether your data set contain rows are not . If it contains then write to xml file using

ds.WriteXML("filename.xml")

Text box Display

I don't understand the Display setting for controls such as text boxes.
I have a text box a button next to it, and then a submit button below
everything so that when the 1st button is pressed, a calendar appears
underneath it.

Becasue the submit button is below all the user input stuff, I want to
make it so that the calendar and the submit buttons are given set
positions on the screen, so that whenever I press the 1st button, my
submit button doesn't get pushed down the screen to make way for the
calendar.

I would've thought Display="Static" would do this, but I get the same
result as using Display="Dynamic". Can anybody help me out with this?

Any help would be really appreciated.

Thanks,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!You need to use absolute display but make sure the parent elements are all
setup - positioning elements in pixel offsets is not a very good thing to
do. Static is meant for something else and IE does not even support it.

Jerry

"Mike P" <mrp@.telcoelectronics.co.uk> wrote in message
news:OVZiJ#UmDHA.2772@.TK2MSFTNGP10.phx.gbl...
> I don't understand the Display setting for controls such as text boxes.
> I have a text box a button next to it, and then a submit button below
> everything so that when the 1st button is pressed, a calendar appears
> underneath it.
> Becasue the submit button is below all the user input stuff, I want to
> make it so that the calendar and the submit buttons are given set
> positions on the screen, so that whenever I press the 1st button, my
> submit button doesn't get pushed down the screen to make way for the
> calendar.
> I would've thought Display="Static" would do this, but I get the same
> result as using Display="Dynamic". Can anybody help me out with this?
>
> Any help would be really appreciated.
>
> Thanks,
> Mike
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Text Box events

I'm trying to disable one text box when a user starts entering data in
a different text box. Is this even possible? If so can someone point
me towards a good example?
Thanks,
JaimeHi Jaime,
You can diable the first Textbox whenevr you type anything in the second
textbox by using this code:
Protected Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox2.TextChanged
Me.TextBox1.Enabled = False
End Sub
Set the AutoPostback property of the second textBox to True and as soon as
the focus from the second textbox is out, the first textbox is disbaled.
Regards,
Manish
www.ComponentOne.com
"jhcruz@.jmaweb.biz" wrote:

> I'm trying to disable one text box when a user starts entering data in
> a different text box. Is this even possible? If so can someone point
> me towards a good example?
> Thanks,
> Jaime
>
"Manish" <Manish@.discussions.microsoft.com> wrote in message
news:A6687B13-88A4-403E-BBD8-37EA92826B7A@.microsoft.com...

> You can diable the first Textbox whenevr you type anything in the second
> textbox by using this code:
> Protected Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles TextBox2.TextChanged
> Me.TextBox1.Enabled = False
> End Sub
> Set the AutoPostback property of the second textBox to True and as soon as
> the focus from the second textbox is out, the first textbox is disbaled.
The above requires a totally unnecessary roundtrip to the server and back...
<asp:TextBox ID="TextBox1" runat="server" />
<asp:TextBox ID="TextBox2" runat="server" />
private void Page_Load(object sender, System.EventArgs e)
{
TextBox1.Attributes.Add("onkeypress", "document.getElementById('" +
TextBox2.ClientID + "').disabled=\"disabled\";");
}
Mark Rae
ASP.NET MVP
http://www.markrae.net

Text box enter

How do I assign a sub to a textbox for when the user hits enter whilst the cusor is still within that textbox?I think you mean how can you execute some code when the textbox is submitted (essentially as event handler). Design your textbox in vs.net...then just double click the textbox and the sub is automatically created for you...then all you have to do is fill in your code.
Hi,

I think you are referring about handling the event for the enter key right?

In your code behind, you will find the handle event for the button click as below:-

Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click

End Sub

you need to add the textbox's text changed event to it as below:-

Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click, TextBox1.TextChanged

End Sub

This should help you.

Thanks.
Many thanks
your welcome!

did that work for you?

thanks.

text box editing

I have a text box where users can enter a reference number. This can be a varchar. I want to use this in a SQL lookup so I want to check for characters that may cause issues in the SQL statement . / _ % and such and escape them so they can still search by these fields? Any suggestions out there?You can use a regular expression to remove characters you don't want like so:

Dim badCharReplace As Regex = New Regex("([<>""'%;()&])")
Dim s As String = badCharReplace.Replace(psInput, "")

Text Box Loses Value On Page Load

Hi Folks...this is a wierd issue I've noticed and wanted to know of a) anyone
else has noticed this and b) if so, why does it happen.

On page load, I have a text box named me.txtMemberName. I enter data into
this field then submit the page. If I check the value of
me.txtMemberName.text during the page load event, it is an empty string. Now,
if I check this again in a later event, the value of .text has the correct
inforamation in it. This is causing me grief b/c, since this is a required
field, Page.IsValid is failing on page load. Any thoughts?

Thanks!

ClayFirst of all, I am assuming you have EnableViewState=True for this Control,
as well as for the Page. Second, can you post your Page.Load procedure so we
can see exactly what you do there and how you do it? This may help me and
others help you solve your problem. Thanks.
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/

"Clayton Hoyt" <ClaytonHoyt@.discussions.microsoft.com> wrote in message
news:1D931693-325B-4116-901F-3D09CF24FE8C@.microsoft.com...
> Hi Folks...this is a wierd issue I've noticed and wanted to know of a)
> anyone
> else has noticed this and b) if so, why does it happen.
> On page load, I have a text box named me.txtMemberName. I enter data into
> this field then submit the page. If I check the value of
> me.txtMemberName.text during the page load event, it is an empty string.
> Now,
> if I check this again in a later event, the value of .text has the correct
> inforamation in it. This is causing me grief b/c, since this is a required
> field, Page.IsValid is failing on page load. Any thoughts?
> Thanks!
> Clay

Text box looping question.

I can do this in regular asp, but i'm a little confused in .net.

There are 5 records in my table. companyid and companyname fields.

If I want to display all five records but as editable textboxes. So each textbox has the companyid from table and companyname as the text value.

Then if they hit save -- it loops through and saves all values in textboxes to the table based on the id.

Do I do put the textboxes inside a repeater?Or do I put the textboxes inside a datalist and do it that way. I'm not sure about the saving procedure.
I think you can use a repeater,

try this (this should definitely work :)):


<asp:Repeater id="myRptr" runat="server">
<ItemTemplate>
<input type=text id='<%# DataBinder.Eval(Container.DataItem, "companyid ") %>'
value='<%# DataBinder.Eval(Container.DataItem, "companyname") %>'>
</ItemTemplate>
</asp:Repeater>

It didn't like that ('<%# DataBinder.Eval(Container, "DataItem.company_id") %>' is not a valid identifier.) so I tried:

<asp:TextBox id="txtName" runat="server" text='<%# DataBinder.Eval(Container, "DataItem.company_name") %>'></asp:TextBox>
<asp:Label ID="lblName" Runat="server" text=<%# DataBinder.Eval(Container, "DataItem.company_id") %>></asp:Label
Then in codebehind
Dim j As RepeaterItem
For Each j In rptName.Items
Response.Write(DirectCast(j.FindControl("txtName"), TextBox).Text & "<br>")
Response.Write(DirectCast(j.FindControl("lblName"), Label).Text & "<br>")
Next

That gives me the companyname and id. Then I can just use update statement in the [for...next] and update.
I tried this way instead and it seems to work.

<asp:TextBox id="txtName" runat="server" text='<%# DataBinder.Eval(Container, "DataItem.company_name") %>'></asp:TextBox>
<asp:Label ID="lblName" Runat="server" text=<%# DataBinder.Eval(Container, "DataItem.company_id") %>></asp:Label
Dim j As RepeaterItem
For Each j In rptName.Items
Response.Write(DirectCast(j.FindControl("txtName"), TextBox).Text & "<br>")
Response.Write(DirectCast(j.FindControl("lblName"), Label).Text & "<br>")
Next
Then I just use update statement inside [for ... next]
You can use either... Repeater is a lighter control though...

All the form data will be post back (there is no looping concept)

You can read a very good MSDN article on control choice here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-whenusedatawebcontrols.asp

Good luck :)
I used:


<asp:TextBox id="txtName" runat="server" text='<%# DataBinder.Eval(Container, "DataItem.company_name") %>'></asp:TextBox>
<asp:Label ID="lblName" Runat="server" text=<%# DataBinder.Eval(Container, "DataItem.company_id") %>></asp:Label>

Behind file


Dim j As RepeaterItem
For Each j In rptName.Items
Response.Write(DirectCast(j.FindControl("txtName"), TextBox).Text & "<br>")
Response.Write(DirectCast(j.FindControl("lblName"), Label).Text & "<br>")
Next

I dont know why you have to do this...

I tested this code piece before i posted it and it works fine with me I do not have to use the DirectCast and all that...

Simple '<%# DataBinder.Eval(Container, "DataItem.company_id") %>' works !!!

Did you databind the repeater to a datasource in the Page_Load ?
What does your [for ...next] loop look like?
I tried it with <asp:textbox not with a regular input box like you have. Sorry. So it will work the way you said.
I call this after I hit save to get the values:

Dim j As RepeaterItem
For Each j In rptName.Items
Response.Write(DirectCast(j.FindControl("txtName"), TextBox).Text & "<br>")
Response.Write(DirectCast(j.FindControl("lblName"), Label).Text & "<br>")
Next

How would you get the values using your way?
Oh yes... about the code behind... you will have to do the FindControl...

I am not sure why you are using 'DirectCast(j.FindControl("txtName")... ' what if you use
this.FindControl("txtName")

I might be wrong... cause I am not sure why you need the DirectCast function...

Let me know

text box misbehaviour

Hi

I have a text box which provides a parameter for a query which does a search against a database. the text will be populated on load. But if I edit the text box like say add a few letters then the search is not working. So I did the search by doing the test query feature of the wizard giving the exact parameter value ,it gave me the results. So I went back again and deleted everything upto the first first letter and manually re-entered the parameter in the textbox and searched this time I got the results. Seems like there is some hidden values in the TextBox which I have to delete manually . Has anyone come across a situation like this . Please advice how to solve this behaviour.

Thanks

How are you pre populating the textbox?

<asp:TextBox id="foo" runat="server">bla bla bla </asp:TextBox>

or

<asp:TextBox id="foo" runat="server" Text="bla bla bla" />

Note how the first way leads to a phantom space in your textbox...


I am populating it from a dataRow cell.

building1TextBox.Text = BuildingAddressTable[0].BuildingAddress;

What do you think

Thanks


hmm.

What does the Text property look like if you view it in the debugger when it is assigned to your parameter collection? Do you seen any phantom characters?


maybe something like this

building1TextBox.Text = Trim(BuildingAddressTable[0].BuildingAddress);

or

building1TextBox.Text = BuildingAddressTable[0].BuildingAddress.ToString().Trim();

not sure about the syntax - could be just .Trim()

This will trim whitespace from the beginning and end of the specified string.

Text box losing most recent Text value

It's me and my registration page again. I have a subroutine that calculates
the total fees the registrant will incur and puts it in a textbox (not a
label because it has to be passed to another page).
txtTotalFees.Text = Format(dblTotalFees, "Currency")
The subroutine works fine IF I call it from PageLoad, or I assign it to a
button for recalculating the total fees, or the user clicks the Reset
button, or if they click a control that has AutoPostback set to true.
Basically anything that loads or postbacks the page.
BUT...When it comes time to submit the page and go to the next page I have
this code:
If IsValid Then
CalcFees() 'recalcs fees and updates textbox
Server.Transfer("Confirmation.aspx", True)
End If
When the user gets to the next page I put the total fees in another textbox.
EXCEPT it isn't updated to most recent total. I know because I can comment
out the "Server.Transfer" so that it stays at the registration page AND THE
CORRECT TOTAL IS DISPLAYED!?!?!
What is it about the Server.Transfer that "forgets" what the value of the
textbox should be?
Ken "BiggMakk" McCroryHi Ken
Try this:
Server.Transfer("Confirmation.aspx", True)
This sets the parameter preserveForm to true, hence preserving any
variables still available.
You can then retrieve the value from your previous page on the
Confirmation.aspx page by using Request.Form("totalFees")
Hope that helps :)
sze
Thanks for the try but I am already using the True to preserve variables.
(See original post. It's there.)
Ken "BiggMakk" McCrory
"sze" <szeying.tan@.gmail.com> wrote in message
news:1110401185.776188.29550@.o13g2000cwo.googlegroups.com...
> Hi Ken
> Try this:
> Server.Transfer("Confirmation.aspx", True)
> This sets the parameter preserveForm to true, hence preserving any
> variables still available.
> You can then retrieve the value from your previous page on the
> Confirmation.aspx page by using Request.Form("totalFees")
> Hope that helps :)
> sze
>
Ah, sorry. I didn't notice it in your code at first glance.
Here's a helpful page from MSDN about preserving state between pages.
http://msdn.microsoft.com/library/d...etweenPages.asp
Hope that helps.
I solved this by using SmartNavigation and turning on Autopostback for every
control that can affect the total fees. Before someone says SmartNav doesn't
work in browsers other than IE, you're right. Someone else in a different
post of mine pointed out Smart Scroller by Strength Technologies at this web
site:
http://www.strengthtechnologies.com...l/Download.aspx
It works even in Firefox.
Now the Total fees gets updated before the user hits the Submit button and
the correct value gets passed to the next page. It also removes the need for
the manual "Recalculate Fees" button that I had on the page.
--
Ken "BiggMakk" McCrory
"Ken McCrory" <klm355t@.removefornospammers.smsu.edu> wrote in message
news:OjfvdfOJFHA.688@.TK2MSFTNGP10.phx.gbl...
> It's me and my registration page again. I have a subroutine that
> calculates the total fees the registrant will incur and puts it in a
> textbox (not a label because it has to be passed to another page).
> txtTotalFees.Text = Format(dblTotalFees, "Currency")
> The subroutine works fine IF I call it from PageLoad, or I assign it to a
> button for recalculating the total fees, or the user clicks the Reset
> button, or if they click a control that has AutoPostback set to true.
> Basically anything that loads or postbacks the page.
> BUT...When it comes time to submit the page and go to the next page I have
> this code:
> If IsValid Then
> CalcFees() 'recalcs fees and updates textbox
> Server.Transfer("Confirmation.aspx", True)
> End If
> When the user gets to the next page I put the total fees in another
> textbox. EXCEPT it isn't updated to most recent total. I know because I
> can comment out the "Server.Transfer" so that it stays at the registration
> page AND THE CORRECT TOTAL IS DISPLAYED!?!?!
> What is it about the Server.Transfer that "forgets" what the value of the
> textbox should be?
> Ken "BiggMakk" McCrory
>
Yeah Ken the control works with FireFox and I.E!!!
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!

Text box losing most recent Text value

It's me and my registration page again. I have a subroutine that calculates
the total fees the registrant will incur and puts it in a textbox (not a
label because it has to be passed to another page).

txtTotalFees.Text = Format(dblTotalFees, "Currency")

The subroutine works fine IF I call it from PageLoad, or I assign it to a
button for recalculating the total fees, or the user clicks the Reset
button, or if they click a control that has AutoPostback set to true.
Basically anything that loads or postbacks the page.

BUT...When it comes time to submit the page and go to the next page I have
this code:

If IsValid Then
CalcFees() 'recalcs fees and updates textbox
Server.Transfer("Confirmation.aspx", True)
End If

When the user gets to the next page I put the total fees in another textbox.
EXCEPT it isn't updated to most recent total. I know because I can comment
out the "Server.Transfer" so that it stays at the registration page AND THE
CORRECT TOTAL IS DISPLAYED!?!?!

What is it about the Server.Transfer that "forgets" what the value of the
textbox should be?

Ken "BiggMakk" McCroryHi Ken

Try this:
Server.Transfer("Confirmation.aspx", True)
This sets the parameter preserveForm to true, hence preserving any
variables still available.

You can then retrieve the value from your previous page on the
Confirmation.aspx page by using Request.Form("totalFees")

Hope that helps :)
sze
Thanks for the try but I am already using the True to preserve variables.
(See original post. It's there.)

Ken "BiggMakk" McCrory

"sze" <szeying.tan@.gmail.com> wrote in message
news:1110401185.776188.29550@.o13g2000cwo.googlegro ups.com...
> Hi Ken
> Try this:
> Server.Transfer("Confirmation.aspx", True)
> This sets the parameter preserveForm to true, hence preserving any
> variables still available.
> You can then retrieve the value from your previous page on the
> Confirmation.aspx page by using Request.Form("totalFees")
> Hope that helps :)
> sze
Ah, sorry. I didn't notice it in your code at first glance.

Here's a helpful page from MSDN about preserving state between pages.
http://msdn.microsoft.com/library/d...etweenPages.asp

Hope that helps.
I solved this by using SmartNavigation and turning on Autopostback for every
control that can affect the total fees. Before someone says SmartNav doesn't
work in browsers other than IE, you're right. Someone else in a different
post of mine pointed out Smart Scroller by Strength Technologies at this web
site:

http://www.strengthtechnologies.com...l/Download.aspx

It works even in Firefox.

Now the Total fees gets updated before the user hits the Submit button and
the correct value gets passed to the next page. It also removes the need for
the manual "Recalculate Fees" button that I had on the page.
--
Ken "BiggMakk" McCrory

"Ken McCrory" <klm355t@.removefornospammers.smsu.edu> wrote in message
news:OjfvdfOJFHA.688@.TK2MSFTNGP10.phx.gbl...
> It's me and my registration page again. I have a subroutine that
> calculates the total fees the registrant will incur and puts it in a
> textbox (not a label because it has to be passed to another page).
> txtTotalFees.Text = Format(dblTotalFees, "Currency")
> The subroutine works fine IF I call it from PageLoad, or I assign it to a
> button for recalculating the total fees, or the user clicks the Reset
> button, or if they click a control that has AutoPostback set to true.
> Basically anything that loads or postbacks the page.
> BUT...When it comes time to submit the page and go to the next page I have
> this code:
> If IsValid Then
> CalcFees() 'recalcs fees and updates textbox
> Server.Transfer("Confirmation.aspx", True)
> End If
> When the user gets to the next page I put the total fees in another
> textbox. EXCEPT it isn't updated to most recent total. I know because I
> can comment out the "Server.Transfer" so that it stays at the registration
> page AND THE CORRECT TOTAL IS DISPLAYED!?!?!
> What is it about the Server.Transfer that "forgets" what the value of the
> textbox should be?
> Ken "BiggMakk" McCrory
Yeah Ken the control works with FireFox and I.E!!!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Text Box Loses Value On Page Load

Hi Folks...this is a wierd issue I've noticed and wanted to know of a) anyon
e
else has noticed this and b) if so, why does it happen.
On page load, I have a text box named me.txtMemberName. I enter data into
this field then submit the page. If I check the value of
me.txtMemberName.text during the page load event, it is an empty string. Now
,
if I check this again in a later event, the value of .text has the correct
inforamation in it. This is causing me grief b/c, since this is a required
field, Page.IsValid is failing on page load. Any thoughts?
Thanks!
ClayFirst of all, I am assuming you have EnableViewState=True for this Control,
as well as for the Page. Second, can you post your Page.Load procedure so we
can see exactly what you do there and how you do it? This may help me and
others help you solve your problem. Thanks.
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/
"Clayton Hoyt" <ClaytonHoyt@.discussions.microsoft.com> wrote in message
news:1D931693-325B-4116-901F-3D09CF24FE8C@.microsoft.com...
> Hi Folks...this is a wierd issue I've noticed and wanted to know of a)
> anyone
> else has noticed this and b) if so, why does it happen.
> On page load, I have a text box named me.txtMemberName. I enter data into
> this field then submit the page. If I check the value of
> me.txtMemberName.text during the page load event, it is an empty string.
> Now,
> if I check this again in a later event, the value of .text has the correct
> inforamation in it. This is causing me grief b/c, since this is a required
> field, Page.IsValid is failing on page load. Any thoughts?
> Thanks!
> Clay

Text box on same line as Radio Buttons

Using ASP.Net1.0
How can I get "Type of degree" and the following text box on the same line
as the radio buttons for "CollegeCompleted"?
I have tried <div style="float:left">, which works well for me in other
areas, but not in this case.
<HR>
College Name <span style="margin-left:162px;">
City/State <br>
<asp:TextBox id="College" columns = "35" runat=server/>
<asp:TextBox id="CollegeCity" columns = "35" runat=server/>
<br>Last Year Completed
<asp:RadioButtonList id="CollegeCompleted" RepeatDirection="horizontal"
Runat=server>
<asp:ListItem><font size="2"> 1</asp:ListItem>
<asp:ListItem><font size="2">2</asp:ListItem>
<asp:ListItem><font size="2">3</asp:ListItem>
<asp:ListItem><font size="2">4</asp:ListItem>
<asp:ListItem><font size="2">5</asp:ListItem>
</asp:RadioButtonList>
Type of Degree: <asp:TextBox id="DegreeCollege" runat=server/>
<HR>On Aug 17, 6:40 pm, "dancer" <dan...@.microsoft.com> wrote:
> Using ASP.Net1.0
> How can I get "Type of degree" and the following text box on the same lin
e
> as the radio buttons for "CollegeCompleted"?
> I have tried <div style="float:left">, which works well for me in other
> areas, but not in this case.
>

> College Name <span style="margin-left:162px;">
> City/State <br>
> <asp:TextBox id="College" columns = "35" runat=server/>
> <asp:TextBox id="CollegeCity" columns = "35" runat=server/>
> <br>Last Year Completed
> <asp:RadioButtonList id="CollegeCompleted" RepeatDirection="horizontal"
> Runat=server>
> <asp:ListItem><font size="2"> 1</asp:ListItem>
> <asp:ListItem><font size="2">2</asp:ListItem>
> <asp:ListItem><font size="2">3</asp:ListItem>
> <asp:ListItem><font size="2">4</asp:ListItem>
> <asp:ListItem><font size="2">5</asp:ListItem>
> </asp:RadioButtonList>
> Type of Degree: <asp:TextBox id="DegreeCollege" runat=server/>
>

Hi dancer,
You should add RepeatLayout="Flow" to RadioButtonList:
<asp:RadioButtonList id="CollegeCompleted"
RepeatDirection="horizontal"
Runat=server RepeatLayout="Flow">
<asp:ListItem><font size="2"> 1</asp:ListItem>
<asp:ListItem><font size="2">2</asp:ListItem>
<asp:ListItem><font size="2">3</asp:ListItem>
<asp:ListItem><font size="2">4</asp:ListItem>
<asp:ListItem><font size="2">5</asp:ListItem>
</asp:RadioButtonList>
Type of Degree: <asp:TextBox id="DegreeCollege" runat=server/>
Regards,
Alexander Kleshchevnikov
MCP
www.klalex.com
That worked well. THANK YOU.
"seigo" <seigo.ua@.gmail.com> wrote in message
news:1187365869.355627.265430@.w3g2000hsg.googlegroups.com...
> On Aug 17, 6:40 pm, "dancer" <dan...@.microsoft.com> wrote:
> Hi dancer,
> You should add RepeatLayout="Flow" to RadioButtonList:
> <asp:RadioButtonList id="CollegeCompleted"
> RepeatDirection="horizontal"
> Runat=server RepeatLayout="Flow">
>
> <asp:ListItem><font size="2"> 1</asp:ListItem>
>
> <asp:ListItem><font size="2">2</asp:ListItem>
>
> <asp:ListItem><font size="2">3</asp:ListItem>
>
> <asp:ListItem><font size="2">4</asp:ListItem>
>
> <asp:ListItem><font size="2">5</asp:ListItem>
>
> </asp:RadioButtonList>
>
> Type of Degree: <asp:TextBox id="DegreeCollege" runat=server/>
> Regards,
> Alexander Kleshchevnikov
> MCP
> www.klalex.com
>

Text Box Problem

Hello,
I have a master page where my form has the Runat="server".
The master page as a control place holder, named "cphContent".
Then in a page which inherits from the master page I added a custom
control which I created.
This custom control is added to "cphContent" at runtime.
The custom control creates and adds 2 textboxes using
CreateChildControls.
I am getting an error:
System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
type 'TextBox' must be placed inside a form tag with runat=server.
I have no idea why do I get this error.
The form with Runat="server" is in the master page.
Anyway, can someone tell me how can I figure what is going on?
Thanks,
MiguelHere is my code.
I am adding and creating all controls at runtime in my pages.
---
Base.master:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="fBase" runat="server"></form>
</body>
</html>
Base.master.vb:
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Init
Dim pContainer As New Panel
AddHandler pContainer.Init, AddressOf pContainer_Init
Me.Controls.Add(pContainer)
Dim cphContent As New ContentPlaceHolder
AddHandler cphContent.Init, AddressOf cphContent_Init
pContent.Controls.Add(cphContent)
End Sub
MyPage.aspx:
<%@. Page Language="VB" CodeFile="Default.aspx.vb" Inherits="_Default"
%>
MyPage.aspx.vb:
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Init
Dim by27fContactForm As New By27.Web.UI.Form.Contact
AddHandler by27fContactForm.Init, AddressOf by27fContactForm_Init
pContacts.Controls.Add(by27fContactForm)
End Sub
Class Contact in Namespace By27.Web.UI:
Namespace Web.UI.Form
' Content
<DefaultProperty("Text"), ToolboxData("<{0}:ContactForm
runat=server></{0}:ContactForm>")> _
Public Class Contact
Inherits WebControl
Dim by27cf_tbName As New WebControls.TextBox
Private Sub by27cf_tbName_Init(ByVal sender As Object, ByVal e As
System.EventArgs)
With by27cf_tbName
.CssClass = Me.TextBoxCssClass
.ID = "by27cf_tbName"
.Width = Unit.Percentage(100)
End With
End Sub
<Bindable(True), Category("Appearance"), DefaultValue(""),
Localizable(True)> Property TextBoxCssClass() As String
Get
If CStr(ViewState("TextBoxCssClass")) Is Nothing Then
Return String.Empty
Else
Return CStr(ViewState("TextBoxCssClass"))
End If
End Get
Set(ByVal Value As String)
ViewState("TextBoxCssClass") = Value
End Set
End Property
Protected Overrides Sub CreateChildControls()
AddHandler by27cf_tbName.Init, AddressOf by27cf_tbName_Init
MyBase.Controls.Add(by27cf_tbName)
' Create child controls
MyBase.CreateChildControls()
Me.ChildControlsCreated = True
End Sub
End Class
---
Thanks,
Miguel
shapper wrote:
> Hello,
> I have a master page where my form has the Runat="server".
> The master page as a control place holder, named "cphContent".
> Then in a page which inherits from the master page I added a custom
> control which I created.
> This custom control is added to "cphContent" at runtime.
> The custom control creates and adds 2 textboxes using
> CreateChildControls.
> I am getting an error:
> System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
> type 'TextBox' must be placed inside a form tag with runat=server.
> I have no idea why do I get this error.
> The form with Runat="server" is in the master page.
> Anyway, can someone tell me how can I figure what is going on?
> Thanks,
> Miguel
This is a bug of Visual Studio. A problem is that in content page you don't
have form
"shapper" <mdmoura@.gmail.com> wrote in message
news:1163016480.466822.19390@.m7g2000cwm.googlegroups.com...
> Hello,
> I have a master page where my form has the Runat="server".
> The master page as a control place holder, named "cphContent".
> Then in a page which inherits from the master page I added a custom
> control which I created.
> This custom control is added to "cphContent" at runtime.
> The custom control creates and adds 2 textboxes using
> CreateChildControls.
> I am getting an error:
> System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
> type 'TextBox' must be placed inside a form tag with runat=server.
> I have no idea why do I get this error.
> The form with Runat="server" is in the master page.
> Anyway, can someone tell me how can I figure what is going on?
> Thanks,
> Miguel
>

Text Box Problem

Hello,

I have a master page where my form has the Runat="server".
The master page as a control place holder, named "cphContent".
Then in a page which inherits from the master page I added a custom
control which I created.
This custom control is added to "cphContent" at runtime.
The custom control creates and adds 2 textboxes using
CreateChildControls.

I am getting an error:
System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
type 'TextBox' must be placed inside a form tag with runat=server.

I have no idea why do I get this error.
The form with Runat="server" is in the master page.

Anyway, can someone tell me how can I figure what is going on?

Thanks,
MiguelHere is my code.

I am adding and creating all controls at runtime in my pages.

----------------------

Base.master:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="fBase" runat="server"></form>
</body>
</html>

Base.master.vb:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Init

Dim pContainer As New Panel
AddHandler pContainer.Init, AddressOf pContainer_Init
Me.Controls.Add(pContainer)

Dim cphContent As New ContentPlaceHolder
AddHandler cphContent.Init, AddressOf cphContent_Init
pContent.Controls.Add(cphContent)

End Sub

MyPage.aspx:

<%@. Page Language="VB" CodeFile="Default.aspx.vb" Inherits="_Default"
%>

MyPage.aspx.vb:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Init

Dim by27fContactForm As New By27.Web.UI.Form.Contact
AddHandler by27fContactForm.Init, AddressOf by27fContactForm_Init
pContacts.Controls.Add(by27fContactForm)

End Sub

Class Contact in Namespace By27.Web.UI:

Namespace Web.UI.Form

' Content
<DefaultProperty("Text"), ToolboxData("<{0}:ContactForm
runat=server></{0}:ContactForm>")_
Public Class Contact
Inherits WebControl

Dim by27cf_tbName As New WebControls.TextBox
Private Sub by27cf_tbName_Init(ByVal sender As Object, ByVal e As
System.EventArgs)
With by27cf_tbName
.CssClass = Me.TextBoxCssClass
.ID = "by27cf_tbName"
.Width = Unit.Percentage(100)
End With
End Sub

<Bindable(True), Category("Appearance"), DefaultValue(""),
Localizable(True)Property TextBoxCssClass() As String
Get
If CStr(ViewState("TextBoxCssClass")) Is Nothing Then
Return String.Empty
Else
Return CStr(ViewState("TextBoxCssClass"))
End If
End Get
Set(ByVal Value As String)
ViewState("TextBoxCssClass") = Value
End Set
End Property

Protected Overrides Sub CreateChildControls()
AddHandler by27cf_tbName.Init, AddressOf by27cf_tbName_Init
MyBase.Controls.Add(by27cf_tbName)
' Create child controls
MyBase.CreateChildControls()
Me.ChildControlsCreated = True
End Sub

End Class

----------------------

Thanks,

Miguel

shapper wrote:

Quote:

Originally Posted by

Hello,
>
I have a master page where my form has the Runat="server".
The master page as a control place holder, named "cphContent".
Then in a page which inherits from the master page I added a custom
control which I created.
This custom control is added to "cphContent" at runtime.
The custom control creates and adds 2 textboxes using
CreateChildControls.
>
I am getting an error:
System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
type 'TextBox' must be placed inside a form tag with runat=server.
>
I have no idea why do I get this error.
The form with Runat="server" is in the master page.
>
Anyway, can someone tell me how can I figure what is going on?
>
Thanks,
Miguel


This is a bug of Visual Studio. A problem is that in content page you don't
have form

"shapper" <mdmoura@.gmail.comwrote in message
news:1163016480.466822.19390@.m7g2000cwm.googlegrou ps.com...

Quote:

Originally Posted by

Hello,
>
I have a master page where my form has the Runat="server".
The master page as a control place holder, named "cphContent".
Then in a page which inherits from the master page I added a custom
control which I created.
This custom control is added to "cphContent" at runtime.
The custom control creates and adds 2 textboxes using
CreateChildControls.
>
I am getting an error:
System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
type 'TextBox' must be placed inside a form tag with runat=server.
>
I have no idea why do I get this error.
The form with Runat="server" is in the master page.
>
Anyway, can someone tell me how can I figure what is going on?
>
Thanks,
Miguel
>
>

Text Box Problem

Hello,

I have a master page where my form has the Runat="server".
The master page as a control place holder, named "cphContent".
Then in a page which inherits from the master page I added a custom control which I created.
This custom control is added to "cphContent" at runtime.
The custom control creates and adds 2 textboxes using CreateChildControls.

I am getting an error:
System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of type 'TextBox' must be placed inside a form tag with runat=server.

I have no idea why do I get this error.
The form with Runat="server" is in the master page.

Anyway, can someone tell me how can I figure what is going on?

Thanks,
MiguelYou may need to show some code of how do you set up the Content page.

Here is my code.

I am adding and creating all controls at runtime in my pages.

----------------------

Base.master:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="fBase" runat="server"></form>
</body>
</html
Base.master.vb:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init

Dim pContainer As New Panel
AddHandler pContainer.Init, AddressOf pContainer_Init
Me.Controls.Add(pContainer)

Dim cphContent As New ContentPlaceHolder
AddHandler cphContent.Init, AddressOf cphContent_Init
pContent.Controls.Add(cphContent)

End Sub

MyPage.aspx:

<%@. Page Language="VB" CodeFile="Default.aspx.vb" Inherits="_Default" %>

MyPage.aspx.vb:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init

Dim by27fContactForm As New By27.Web.UI.Form.Contact
AddHandler by27fContactForm.Init, AddressOf by27fContactForm_Init
pContacts.Controls.Add(by27fContactForm)

End Sub

Class Contact in Namespace By27.Web.UI:

Namespace Web.UI.Form

' Content
<DefaultProperty("Text"), ToolboxData("<{0}:ContactForm runat=server></{0}:ContactForm>")> _
Public Class Contact
Inherits WebControl

Dim by27cf_tbName As New WebControls.TextBox
Private Sub by27cf_tbName_Init(ByVal sender As Object, ByVal e As System.EventArgs)
With by27cf_tbName
.CssClass = Me.TextBoxCssClass
.ID = "by27cf_tbName"
.Width = Unit.Percentage(100)
End With
End Sub

<Bindable(True), Category("Appearance"), DefaultValue(""), Localizable(True)> Property TextBoxCssClass() As String
Get
If CStr(ViewState("TextBoxCssClass")) Is Nothing Then
Return String.Empty
Else
Return CStr(ViewState("TextBoxCssClass"))
End If
End Get
Set(ByVal Value As String)
ViewState("TextBoxCssClass") = Value
End Set
End Property

Protected Overrides Sub CreateChildControls()
AddHandler by27cf_tbName.Init, AddressOf by27cf_tbName_Init
MyBase.Controls.Add(by27cf_tbName)
' Create child controls
MyBase.CreateChildControls()
Me.ChildControlsCreated = True
End Sub

End Class

----------------------

Thanks,

Miguel


The controls are not being added between the form tags. Add a placeholder to the masterpage and add your controls (panel/contentholder) to that, instead of the page.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="fBase" runat="server">
<asp:PlaceHolder id="ControlHolder" runat="server"/>
</form>
</body>
</html>


In this line

pContent.Controls.Add(cphContent)

What and/or where is "pContent"? It isn't entirely clear where you're getting it from.


It should be pContainer and not pContent.

It was a mistake when coping it to here. I just copied parts of the code to give an idea


shapper:

Base.master:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="fBase" runat="server"></form>
</body>
</html
Base.master.vb:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init

Dim pContainer As New Panel
AddHandler pContainer.Init, AddressOf pContainer_Init
Me.Controls.Add(pContainer)

Dim cphContent As New ContentPlaceHolder
AddHandler cphContent.Init, AddressOf cphContent_Init
pContent.Controls.Add(cphContent)

End Sub

In the Page_Init above, you are adding a Panel to thepage, but not to theform. Therefore, cphContent is not in the form. And when you add the custom control to cphContent, then obviously that's not in the form either.

Text box reading old value

Hi i am trying to create a simple page that would allow users to edit there infromation that is stored on them,

It loads the information from the database fine and puts it into the textbox's but then on the "update" button it doesnt get the changed values

e.g

if the textbox was set on the page load to "bren" and then i changed it on the page to be "Hello" when i execute the onlclick function of the button it still reads as "bren"

using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.Odbc;public partialclass user_userDetails : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) {if (!HttpContext.Current.User.Identity.Name.Contains(ConfigurationManager.AppSettings["siteGSTPrefix"])) {string userGuid = HttpContext.Current.User.Identity.Name; OdbcConnection detailsCon = sqlconnect.Connect(); OdbcCommand detailsCom =new OdbcCommand("SELECT tbl_usr.Username,tbl_usr_info.first_name,tbl_usr_info.second_name,tbl_usr_info.address_line_1,tbl_usr_info.address_line_2,tbl_usr_info.address_line_3,tbl_usr_info.post_code,tbl_usr_info.home_phone,tbl_usr_info.work_phone,tbl_usr_info.email_addy FROM tbl_usr INNER JOIN tbl_usr_info ON tbl_usr.usr_guid = tbl_usr_info.usr_guid WHERE tbl_usr.usr_guid='" + userGuid +"'", detailsCon); OdbcDataReader detRead = detailsCom.ExecuteReader();while (detRead.Read()) { userNote.Text ="Your Password is not displayed for security!"; userName.Text = detRead["Username"].ToString().Replace("#@dotnet.itags.org.","'"); fName.Text = detRead["first_name"].ToString().Replace("#@dotnet.itags.org.","'"); sName.Text = detRead["second_name"].ToString().Replace("#@dotnet.itags.org.","'"); aD1.Text = detRead["address_line_1"].ToString().Replace("#@dotnet.itags.org.","'"); aD2.Text = detRead["address_line_2"].ToString().Replace("#@dotnet.itags.org.","'"); aD3.Text = detRead["address_line_3"].ToString().Replace("#@dotnet.itags.org.","'"); pCode.Text = detRead["post_code"].ToString().Replace("#@dotnet.itags.org.","'"); hPhone.Text = detRead["home_phone"].ToString().Replace("#@dotnet.itags.org.","'"); wPhone.Text = detRead["work_phone"].ToString().Replace("#@dotnet.itags.org.","'"); eAddy.Text = detRead["email_addy"].ToString().Replace("#@dotnet.itags.org.","'"); } detRead.Close(); detailsCon.Close(); }else { Response.Redirect(FormsAuthentication.LoginUrl); } }protected void update_click(object sender, EventArgs e) {string userGuid = HttpContext.Current.User.Identity.Name;string passSettings =string.Empty; Response.Clear();if(userPass.Text.ToString() !="" && userPass.Text.ToString() !=null) { passSettings =" , tbl_usr.Password = '" + userPass.Text.ToString().Replace("'","#@dotnet.itags.org.") +"'"; } OdbcConnection detCon = sqlconnect.Connect(); OdbcCommand upCom =new OdbcCommand("UPDATE tbl_usr SET tbl_usr.Username = '" + userName.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' " + passSettings +" WHERE tbl_usr.usr_guid = '" + userGuid +"'", detCon); upCom.ExecuteNonQuery(); OdbcCommand upComInfo =new OdbcCommand("UPDATE tbl_usr_info SET tbl_usr_info.first_name = '" + fName.Text.Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.second_name = '" + sName.Text.Replace("'","#@dotnet.itags.org.").Trim() +"' , tbl_usr_info.address_line_1 = '" + aD1.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.address_line_2 = '" + aD2.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.address_line_3 = '" + aD3.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.post_code = '" + pCode.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.work_phone = '" + wPhone.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.home_phone = '" + hPhone.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.email_addy = '" + eAddy.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' WHERE tbl_usr_info.usr_guid = '" + userGuid +"'", detCon); upComInfo.ExecuteNonQuery(); userNote.Text ="Your details have been updated"; }}


Thanks for your help in advance

Dan

your update_click is happening after the page_load. try changing the code you have in page_load to page_prerender and see if you are good to go.


i have treid to user it with IsPostBack but it doesnt work,

i didnt think that Page_load was re run when u clicked on a button and ran the function

Dan


Fixed it now thanks changed it to a !IsPostBack and it now works thanks