简体   繁体   English

自动生成的表单值

[英]Auto-generated Form Value

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. 寻找有关如何在ASP.NET Web窗体中实现某些功能的指南-该行为有点类似于ASP.NET AutocompleteExtender中的行为,但是我找不到能够提供所需灵活性的任何东西。 Here is what I am trying to do: 这是我正在尝试做的事情:

  • 2 TextBox fields on the form, CompanyName and CompanyRef (CompanyRef an abbreviated unique Company identifier) 表单上的2个TextBox字段,CompanyName和CompanyRef(CompanyRef是唯一的公司标识符的缩写)
  • User types in the CompanyName CompanyName中的用户类型
  • As soon as there are 3 characters in the CompanyName an internal webservice is called (AJAX?) 只要CompanyName中包含3个字符,就会调用内部Web服务(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. Webservice检查到目前为止已输入的内容,并评估它的3个字符表示形式,例如,“ Stack”将作为STA0001返回。
  • If there is already an STA0001 in the db it would return STA0002 and so on 如果数据库中已经有STA0001,它将返回STA0002,依此类推
  • The value returned would be targetted at the CompanyRef TextBox 返回的值将定位在CompanyRef TextBox上
  • User needs to be able to edit the CompanyRef if they so wish 用户需要时可以编辑CompanyRef

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. 在Google上进行谷歌搜索和搜索均未返回任何内容-不确定我是否在寻找正确的东西。

Generating the CompanyRef is easy enough. 生成CompanyRef很容易。 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. 您可以使用AJAX调用Web服务并返回当前可用的值,然后使用javascript更新该字段。 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 我已经完成了一篇关于使用jQuery调用Web服务等的文章,这应该为您提供AJAX部分的起点: http : //www.mikesdotnetting.com/Article/104/Many-ways-to-communicate-with-your数据库使用jQuery-AJAX和ASP.NET

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM