VB .net Web Form will not get contents of Text Box

I have created a web form with text boxes that are bound to a DataSet/DataView.  I have created button to navigate up and down the recordset.  That all works fine.

I need to have the ability to edit/add text in any of the boxes and then when clicking "Save" button, it would build an UPDATE query to send to the database.

When the Save button is clicked, I have coded to DIM a string var (strSQL) to use to build the SQL command.  For some reason, it will only get the text from a text box if the data was pulled the database.  If I add/edit data, then the SQL command will have a blank spot where normally it would pull the text from the text box.

Any ideas would be GREATLY appreciated.

0
gr8britton
5/19/2005 11:36:36 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

6 Replies
2464 Views

Similar Articles

[PageSpeed] 31

Please show us some code displaying how you get the TexBox values in your Update method.
Regards

Andre Colbiornsen
---------------------------------
Seventh Day
Råbygatan 1A,
SE-223 61 Lund
Sweden
Mob.: +46-(0)708-97 78 79
Mail: info@seventhday.se
--------------------------------
0
adec
5/20/2005 12:56:06 AM
Hi,
When you populate the textboxes - do you check whether Page.IsPostback is true/false?
Until you post som code, I'm guessing you're not.

if (!IsPostBack) {

    // Populate textboxes
}
else {

    // It is a postback, the Save button
    // shold have an .Click event to handle
    // the new data
}


That help?

--
Tarjei

0
tarjei
5/20/2005 8:55:01 AM

First, thank you for the quick responses.  I will address each item below, including my code.

1 - No, I do not check to see if Page.IsPostback is True or False
2 - A few notes re: the code below:

      A - Originally, I just created a SQL string, DIMed a SQLCommand and then opened the connection, Executed the Query and closed the connection
      B - When that did not work, I REMed out the connection/excution to just try to see what I was getting by posting the string into a text box.  That is how I found out that it was not grabbing the text if it had been edited.
      C - Again, this works fine if it grabs text that came from the database record.  However, if I edit or add text to the text box, the text will not go into the string.

I am new to VB .net and webforms, although I have extensive experience with VB6 and VBA.  Is there something re: the order that the form processes the screen which is causing my app to clear the box BEFORE it reads the text that has been entered?

----------

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
    'Update any changes
    'Insert code to create SQL UPDATE command (cmdEventsUpdate)
    Dim strSQL, strPlan As String
    'Dim cmdEventsUpdate As New SqlClient.SqlCommand(strSQL, cnEvents)
    strPlan = txtLocation.Text
    strSQL = "UPDATE Observed_Events SET Event_Plan = '" & strPlan & "' WHERE (Event_num = " & txtEvent.Text & ")"
    txtSitelayout.Text = strSQL

    'cnEvents.Open()
    'cmdEventsUpdate.ExecuteNonQuery()
    'cnEvents.Close()
End Sub

0
gr8britton
5/20/2005 3:25:55 PM
 gr8britton wrote:

1 - No, I do not check to see if Page.IsPostback is True or False

Well there's your culprit right there. You populate your Textboxes on every PostBack. This means that the values you get when trying to Update are always the ones you get from Db. Remember, Page_Load is always run. This is why you need to check for PostBack like suggested above:

Sub Page_Load(ByVal s As Object, ByVal e As EventArgs)

   If Not IsPostBack Then
      'DataBind your TextBoxes the first time and only then
   End If

End Sub

 

This is all you need to do. When the User Clicks the update Button, it's a PostBack and no DataBinding will take place in Page_Load. Your Sub 'btnSave_Click' will take over and update your Data.


Regards

Andre Colbiornsen
---------------------------------
Seventh Day
Råbygatan 1A,
SE-223 61 Lund
Sweden
Mob.: +46-(0)708-97 78 79
Mail: info@seventhday.se
--------------------------------
0
adec
5/20/2005 4:22:15 PM
Thank you for educating me on that.  I had a feeling something was happening before I was populating my string.  I will give this a shot and post the results.
0
gr8britton
5/20/2005 4:30:31 PM

Thank you for educating me on that.  I had a feeling something was happening before I was populating my string.

I applied your suggestion and it works great.  Thank you so much for help!

0
gr8britton
5/20/2005 4:42:04 PM
Reply:

Similar Artilces:

windows forms in vb .net into web forms
we are creating a database driven website as part of our project. currently we have forms connecting to the database created in visual basic. these windows forms we need to convert into web forms which are asp .net compatible. can u give me an answer or show me a way. Hi, because of the difference in nature between web and win applications you'll need to reimplement at least the UI part. If you have a multitiered application in which the busines logic and data access are in different parts/assemblies you can reuse them. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Wor...

Load Text box of one web form with selected list item of list box of another web form
one help please Problem is i have two web forms  1.  ForiegnkeyTest.aspx  2. foroginkeytable.aspx   step 1 1 ForiegnkeyTest.aspx one web form <head runat="server"><script language="javascript" type="text/javascript">   function popWin()   {         var confirmWin = null;      confirmWin = window.open('foroginkeytable.aspx','anycontent',   'width=455,height=435,status');   }  </script> &...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Web Form vs. Web Content Form
If you don't mind, I would like to know what is the difference between those two items, when I go to add a new item I see both of those and I don't know what the difference is.  A content form is for use with a masterpage. A web form is a standalone web page. If you select web content form, you will then have to specify a masterpage for it. and what is a master page used for?  Hi, a master page is used to give a constant look and theme to a site, without having to duplicate code. So basically you can put your header, menu, nav and footer on a master page. Then a...

getting start with vb.net and crystal repots(web form)
I use Crystal Report9 in Visual Studio.NET 2003..... Example at Northwind database I want a application that.....a form include a combobox that contain CustomerID.....If I choose one CustomerID and click OK button....a Report will display information about this Customer......I think that must use Paramater.....how to do that ???? (How do I start to coding --please step by step or sample) please help me !!! Thank you so much!!! very good I have Dropdownlist when I choose the 'month'--> the all data of this field will show I use this Private Sub ddlMonth_Sel...

.Net Web Form & Web Service Deployment
Hi all I have written some test web services and some web form applications and deployed them to my IIS. That's fine but I now want to deploy them to my real IIS server. I have created an msi for each but the problem is I seem to only be able to deploy to the default web site. Our default web site is turned off and instead we use several other sites. Does anybody happen to if Powerbuilder 11 supports non default web sites? If not do I need to hack the msi and if so can anybody suggest a suitable tool. I have Orca but it's not very friendly. Unless of course I knew exactly w...

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

login form for web services vb.net
Hi, I'm trying to create a windows form with  web services that check if the user and password are the same within the SQL SERVER DATABASE, if its the same then your a valid user if not your an invalid user. That is working ok, but I want to implement a try statement which only allows the user to enter in the details 3 times then the windows form shuts down. also if they do have it correct then another window opens up. ANY HELP PLEASE OR IF SOME 1 KNOWS HOW TO DO IT IN  ASP.NET :>  HERE THE CODE: <WebMethod()> _     &nbs...

Deploying Vb.Net Web Forms on the server
I created a setup file for my first test Web Application. It has a few forms that I like to test on the server. What do I have to do on the server for it to work properly. I have it working on my dev machine. What do I have to install and is there any changes that I have to make to machine.config or any other files. I am using the default settings in Global and web.config files. These files were generated by the Vb.Net 2003. I have been reading on this for awhile and like to make sure of the steps I have to follow. Any help will be greatly appreciated....

Looping through controls in VB.Net Web Form
I need to disable every imagebutton. In VB6, I would have done it like this: 1 Dim iButton As ImageButton 2 For Each iButton In Me.Controls 3 iButton.Enabled = False 4 Next In .Net, I get a "Specified cast is not valid" errror on line 2. Using Page.controls in place of Me.Controls also produces the same error. So, I tried this (and multiple variations): 1 Dim ibControl As Object 2 For Each ibControl In Me.Controls 3 If TypeOf ibControl Is ImageButton Then 4 ...

Creating a web form in VB.NET 2003
I apologise if this has been asked a thousand times.  Firstly, I am using VB.NET 2003 (v7.1.3088) and .NET Framework 1.1.4322  SP1 on WinXP Professional SP2 platform with all security and critical updates in place.My background: good old FoxPro, VB6 and VBA under Access (yuk!)I am playing about with a test project before hopefully upgrading to VB.NET 2005 and i am having a fundamental problem with web forms for a ASP.NET web application.  Whenever I copy and paste an object (text box, label, etc) VB.NET pastes the object back onto the form apparently correctly.  After up...

For interrupting.web form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form
Web Form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form ! Because of my pool English, if you can't see , I will explain more ! ThanksGambler is the real life I guess you mean when form grows it also grow parent div element. This is normal. If you want div to stay fixed size and rather clip the form and maybe show a scrollbar, look at overflow property in CSS.Thanks------------------------------------------------------------This posting is provided "AS IS" with no warranties, and confers no ...

Web Form embedded in another Web Form
Hi,  I have programmed a Web Form which acts like a scientific calculator. I would like to embedd this calculator in the upper left hand corner of another accounting Web Form. I don't want to host the calculator on the same server as the accounting page. I.e. I want them to have distinct URLs. Classically, I would do this using frames, but is there a better way using ASP? Is there some sort of Panel which can display the webpage at a specific URL which I can just drag onto my accounting Web Form? Thanks,  P1000   Frames are the only way to embed a webform inside ano...

Web resources about - VB .net Web Form will not get contents of Text Box - asp.net.web-forms

Help:Contents - Wikipedia, the free encyclopedia
Templates are special pages that contain boilerplate text intended to be displayed on more than one page in Wikipedia. This Tip of the day box ...

Portal:Contents/Society and social sciences - Wikipedia, the free encyclopedia
A society is a group of people who form a semi-closed system . At its simplest, the term society refers to a large group of people sharing their ...

Bad news if you watch Netflix content from other countries: proxies will soon be blocked
There’s bad news for anyone who uses a proxy service to access Netflix content from outside their own country: the company says in a blog post ...

How to Select Sharable Curated Content
Creating and delivering fresh content on a frequent and consistent basis can be a challenge in today’s demanding digital world. Curated content ...

There’s one big way Netflix is actually spending less money on content
Netflix has said it will spend $5 billion on content in 2016 , but there is one important way it will actually spend less, according to analysts ...

You can forget about streaming US Netflix content abroad
The streaming service's catalog of TV shows and movies varies widely from country to country, but you're just going to have to deal with it. ...

Google makes shuffling Drive contents easier
New Move and Add buttons make moving Drive files easier.

You May Soon Not Be Able To Access Any International Netflix Content You Want
... day , Netflix is effectively available worldwide, it looks like the reins are going to be tightened. In a new blog post , Netflix VP of Content ...

The Marketplace of Content
... At the time, only a small fraction of people were online, and even fewer used what we know today as the web for work. Gates saw that “content ...

Netflix stopping ‘unblockers’ accessing content from other countries
... proxies or “unblockers” to trick the streaming video service into thinking they’re in a different country as a way of accessing extra content. ...

Resources last updated: 1/16/2016 4:18:04 PM