0

I am developing a custom tag for asp.net I want to read data from this tag database and return it as a class object and use it on aspx pages.

My code:

 private T RenderControl<T>(Control control)
    {
        T test = (T)Convert.ChangeType(GetType(DataSource), typeof(T));
        test = WebFramework.GetSingleData<T>(SQL, SQLParams.ToArray());
        return test;
    }
    protected override void RenderContents(HtmlTextWriter output)
    {
        output.AddAttribute(HtmlTextWriterAttribute.Id, this.ID);
    }

how can I do that? Example:

<a1:SingleOrDefault ID="test" runat="server" DataSource="MyProject.Models.Members" SQL="SELECT * FROM Members WHERE ID=1"></a1:SingleOrDefault>
<%= test.UserName %>

Thank you.

Selahattin
  • 63
  • 1
  • 2
  • 6

1 Answers1

0

You could use JSON to convert the object to and from strings, and have your asp.net method work with strings rather than object. JSON can be interpreted in any almost language, server side and client side.

Example: https://stackoverflow.com/a/2246724/8250558

Netwtonsoft is very popular: https://www.newtonsoft.com/json

Moffen
  • 1,817
  • 1
  • 14
  • 34
  • no problem with json with the following: use objects in the class via tag. Example tag id: test use: <%= test.UserName %> i want to use this way – Selahattin Nov 26 '18 at 20:59