Click here to Skip to main content
15,886,783 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Basically, its pretty stupid, that when i run the program, and get to a certain page, the CustomerNo value is already in the box, and if i enter the rest of the details and press buy.. it comes up with a generic error message.

BUT

however if i come to the same page, and like before the CustomerNo is already in the box on load up. but if i basically replace that number with the same number so i basically, replace 1 with 1.. i fill the details in again and it works....


I literally do not understand this one bit.

It works if type in ALL of the details, but when i program the textboxes to have the values already in them it doesnt work... its like it only works when i type them all in.

WTF!!
Posted
Updated 10-May-14 15:53pm
v2
Comments
[no name] 10-May-14 21:27pm    
You should not be doing that anyway. Your textbox is data bound to a property named "CustomerNo" so there is no reason at all that you should be trying to set the text directly like that.
[no name] 10-May-14 21:34pm    
This is my problem see. All i want is to be able to insert data into a data service and then a SQL database... i can do that. but soo much unessecary stuff is being done alongside it. so i just wanted to make it simple
[no name] 10-May-14 22:38pm    
Okay. Please do not take this the wrong way because I know that this is going to sound harsh, especially in a written form. Try real hard to think of this a some sort of "fatherly advise" and not some mean old guy putting you down. I want you to succeed, I really do. Let's talk about some facts of life for a second. You have to think of us as someone that has no idea at all what it is that you are trying to do, what your code looks like, what database you are using, how you connect to that database, what data is in your database, what errors you see on your screen or what inner exceptions are popping up. We can only give you answers based on the information that you give us. Now telling us "doesn't work" is the equivalent of walking into your mechanics garage and saying "car broke" and walking out. Do you really think your mechanic could fix your car based on that? We have no idea at all what it is that you think "doesn't work" means because it does work. It works for thousands of others and it can work for you too. Why it does not work for you we cannot say because you are not telling us what you see, what data is supposed to be there, what this property is, nothing. And, what does "doing it in code view" even mean? So back to your code. You have a text box the is databound to some property somewhere named "CustomerNo". Where this property is or what it does or how it relates to your problem, we would have no idea because you are not showing us. I really, really suspect that you have taken on this project and tried to implement techniques without really understanding what it is that you are trying to do and as a result, you are unable to understand the errors that you are getting or how to debug the code that you have. The other error you get, this generic web service error, since we don't know anything the web service, how would you think that we can tell you what is wrong with it? If you really wanted this to be simple, why did you do it this way? Why did you not simply use ADO.NET and connect directly with your database server and run your queries? That way, you know what is going on and you know what the query is doing. I really think that you have possibly taken on a bit too much at one time and might be better of taking a step back and actually doing things simpler instead of trying to do all of this indirect behind-the-scenes magical processing that is not well understood. Hopefully, that helps a little bit. If so, great. If not, sorry. I can see the frustration mounting but there really is not a whole lot we are able to do based on the information that you give us.
[no name] 10-May-14 22:43pm    
I do apologise for my lack of information! But I'm a uni student and my tutors have pretty much thrown me into the deep end and given my an assignment that I know very little about!
The truth is I really couldn't tell you what my code says, the annoying thing is I can't write out the question properly as I have no idea what's going in my self! I'm just pretty much clueless on this entire thing! Like j said my tutor pretty much threw me in the deep end and expects me to finish this program, by Friday! And I'm starting to struggle really badly!
I do apologise for my lack of information on the question, at this point I'm just so fed up with it that nothing is making sense anymore!
[no name] 10-May-14 22:55pm    
As unbelievable as it may seem, I do understand all of that. Being new and under pressure is no fun. And I do empathize with you. To be brutally honest with you, you would be waaaaaaaaaaaaaaaay better off going back to your tutor and have them walk through all of this with you. They are there with you and are in a far better position to help you than we are. You will get far more out of this if you make them explain it to you in terms that you can understand, 5 or 6 times if need be.

Some varibale like CustomerNo will be used to store textbox value.
Just check if it is initialized on load.
 
Share this answer
 
Try to set the value of text box in page_load function such as:-

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
textbox1.Text="value";
}
}
 
Share this answer
 
Just check if variable CustomerNo is initialized on load.
 
Share this answer
 
XML
<script type="text/javascript">

    $(document).ready(function () {
        ClearValue();
    });

    function ClearValue() {

        var textboxID = document.getElementById(textbox);

        if (textboxID.innerHTML == null) {

            textboxID.innerHTML = "";
        }

    }

</script>
 
Share this answer
 

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



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