Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

callback and textbox value

Status
Not open for further replies.

jimktrains

IS-IT--Management
Jan 19, 2007
50
0
0
US
I am learning asp.net and using C# as the code behind. So far so good but I am trying to use callbacks. What I am trying to do is have the user enter a vehicle ID and click a Find button. I want to use the callback to see if an image file exists which would the the vehicle ID with a .jpg extension. But the problem is, when I try to access the value of the textbox the user entered the vehicle ID in, it is blank/null. The coding for the callback works as I tested returning the current date to the client side and displayed it using alert in the javascript. If I display the value of the textbox instead of the date, nothing shows. The textbox and button are both asp controls so that may be why, but being asp controls, how can I find the value without a postback.

I hope I explained this well enough.

Jim
 

By callback I assume you mean you are using Ajax to look up and then return the match (if it exists) ?

K
 
I am not using AJAX. I am using the ICallbackEvent Handler.

I am currently using Visual Web Developer Express 2005 and I cannot find the AJAX tools to load into it. I did download something that should have worked, but the page with the directions no longer exists.
 
jim it sounds like you are using webforms for your html engine. webforms uses the asp.net framework, but it isn't asp.net. it's a subtle difference but makes a huge difference in understanding what is possible.

in all honesty I would recommend not learning webforms. it's a complicated, inter-twined abstraction to produce something very simple... html.

since you are just starting out, take a look at MS MVC for asp.net. MS MVC is a different approach to generating webpages. With this approach there is no need for "server controls", "postbacks" etc. these concepts don't exist outside of the webforms html engine.

MVC stands for Model, View, Controller. where Model is the objects you want to display (customer, order, user, shopping cart, etc) View is the html (which you actually get to control, unlike webforms) and Controller is the entry point into loading the model into the view.

ajax also becomes much easier with MVC because an ajax request is just another url route like any other page. unlike webforms where you need to wire up callbacks and concern yourself with viewstate, postbacks and the page life cycle.

for more information on the topic google "MS MVC vs Webforms".

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Asp.net ajax would be a lot easier here, but if you want to use the ICallbackEventHandler then why not pass the value of the textbox to the callback function?

I wrote a FAQ on this a long time ago. I got pretty bad reviews on it but I'm honestly not sure why...anyway, for what it's worth here it is:


Check out the "eventArgument" part. That should get you there.

Like I said before though, a much easier way to do this is by wrapping what you want to do with an asp.net ajax updatepanel.

Regards,

J
 
Like I said before though, a much easier way to do this is by wrapping what you want to do with an asp.net ajax updatepanel.
easy yes, efficient no. an updatepanel preforms a full postback wrapped in an ajax request. the only benefit is the user does not see a full screen refresh. if this is a high traffic site, then updatepanel is the worst choice. here is an article detailing the topic:

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
I believe the ICallbackEventHandler does the same thing if I remember correctly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top