如何在asp.net c中的文本框中生成数字# [英] how to generate number in textbox in asp.net c#

查看:100
本文介绍了如何在asp.net c中的文本框中生成数字#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨frnds,



我的项目中有一个注册表,当用户打开此页面时,必须在文本框中自动生成代码。

所以我们可以理解,这是这个用户的代码。



代码必须生成为(UserDepartment-001)

例子

===========

UserIT-001

UserIT-002

UserIT-003



当页面加载时,代码必须在文本框(TxtGeneratedCode)中自动生成。



请你能帮我解决这个问题。



提前致谢。

Hi frnds,

I have a registration form in my project, when user open this page a code number must be generated automatically in textbox.
so we can understand, this is the code for this user.

The code must be generated as (UserDepartment-001)
Example
===========
UserIT-001
UserIT-002
UserIT-003

The code must be automatically generated in Textbox(TxtGeneratedCode) when the page loads.

Please can you help me how to do this.

Thanks in advance.

推荐答案

没有。不要这样做。不要尝试。



您认为有多少用户会同时注册?一个,或多个?



如果它不止一个 - 它将在现实世界中 - 并且你预生成用户代码,那么所有当前用户都将获得保存价值。



只有在将它们插入系统时才生成用户ID等等:因为只有这样才能确定他们可以拥有多少价值 - 想想你可以与多个具有相同价值的人一起遇到多少麻烦?



那么,究竟如何生成代码将取决于你如何存储它...
No. Don't do it. Don't even try.

How many users do you think will be trying to register at the same time? One, or more than one?

If it's more than one - and it will be in the real world - and you "pre-generate" the user code, then all the current users will be given teh save value.

Only ever generate user ids and so forth when you insert them to the system: because only then can you be sure exactly what value they can have - think how much trouble you could get into with more than one person with the same value?

Then, exactly how to generate the code will depend on how you are storing it...


参考:使用SQL Server自定义自动生成的序列 [ ^ ] [我假设您使用的是SQL Server]。



我同意OG的内容上面说明并使用此链接你笑uld在插入记录时生成数字。
Refer this : Custom Auto-Generated Sequences with SQL Server[^][I assume you are using SQL Server].

I am agree with what OG stated above and using this link you should generate the number at the time of insertion of record.


这篇关于如何在asp.net c中的文本框中生成数字#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆