开发者

Automated WebForm Generation

开发者 https://www.devze.com 2023-01-17 15:16 出处:网络
I have a bunch of C# functions with string, int and bool arguments that serve as data entry interfaces.I\'d like to be able to create a webform for each method; a textbox for each 开发者_运维技巧strin

I have a bunch of C# functions with string, int and bool arguments that serve as data entry interfaces. I'd like to be able to create a webform for each method; a textbox for each 开发者_运维技巧string/int and a checkbox for each bool.

Is there a way to automate this process?


You'd need to use reflection to retrieve the methods' signature and then create a web form based on its parameter

// Create a container (panel for instance)

var parameters = methodInfo.GetParameters();
foreach (var parameter in parameters)
{
  if (parameter.ParameterType == typeof(string))
  {//Create a text box and add it to the panel}
  else if (parameter.ParameterType == typeof(int))
  {//Create a numeric box and add it to the panel}
...
}
0

精彩评论

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