开发者

Automated WebForm Generation

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜