开发者

Auto-generated Form Value

开发者 https://www.devze.com 2022-12-11 17:55 出处:网络
Looking for guidance on how to achieve something in ASP.NET Web Form - the behaviour is a bit like that seen in ASP.NET AutocompleteExtender, but I can\'t find anything that gives the flexibility I ne

Looking for guidance on how to achieve something in ASP.NET Web Form - the behaviour is a bit like that seen in ASP.NET AutocompleteExtender, but I can't find anything that gives the flexibility I need. Here is what I am trying to do:

  • 2 TextBox fields on the form, CompanyName and CompanyRef (CompanyRef an abbreviated unique Company identifier)
  • User types in the CompanyN开发者_如何学Pythoname
  • As soon as there are 3 characters in the CompanyName an internal webservice is called (AJAX?)
  • Webservice checks what has been entered so far and evaluates a 3 character representation of it - for instance "Stack" would be returned as STA0001.
  • If there is already an STA0001 in the db it would return STA0002 and so on
  • The value returned would be targetted at the CompanyRef TextBox
  • User needs to be able to edit the CompanyRef if they so wish

I'm not looking for code per se, more high level guidance on how this can be done, or if there are any components available that I am missing that you may be able to point me in the direction of. Googling and searching on SO has returned nothing - not sure if I'm looking for the right thing though.


Generating the CompanyRef is easy enough. There are lots of articles etc which cover combining say an autonumber or counter with a string. The difficulty I have with your approach is that you intend to let users fiddle with the ref, and make their own up. What for?

[EDIT - Follow up to comment]

The comment box didn't allow for enough characters to answer your comment fully (and I'm still getting used to the conventions in place here....)

You could use AJAX to call the web service and return currently available values, and then use javascript to update the field. The problem with this is that once a user has decided he or she likes one, it may no longer be available when it is passed back to the database. That means you will have to do one final check, which may result in a message to the user that they can't now have the value they were told was available when they started the process. Only you know the likelihood of this happening. It will depend on the number of concurrent users you have.

I've done an article on calling web services etc using jQuery which should give you a starting point for the AJAX part: http://www.mikesdotnetting.com/Article/104/Many-ways-to-communicate-with-your-database-using-jQuery-AJAX-and-ASP.NET

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号