Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Setting ASP.NET page controls from class library assembly

Setting ASP.NET page controls from class library assembly

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdesign
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chesnokov Yuriy
    wrote on last edited by
    #1

    I use model view presenter approach for ASP.NET web site. The presentation part is compiled in separate class library where view contracts and presenters are defined:

    MyPresentation assembly
    IMyView
    {
    DisplayText(string text);
    }
    MyPresenter
    {
    public IMyView View { get; set; }
    public DisplayText()
    {
    string text = Generate();
    View.DisplayText(text);
    }
    }

    MyWebApplication assembly
    public partial class MyForm : System.Web.UI.Page, IMyView
    {
    public void DisplayText(string text)
    {
    this.myLabel.Text = text;
    }
    ...
    protected void myButton_Click(object sender, EventArgs e)
    {
    Presenter.DisplayText(); // calls this.DisplayText()
    }
    }

    However after stepping out of Presenter.DisplayText() Text property of myLabel becomes null again as though no assignment were done. By all means if you replace the only line in myButton click event with direct setting of myLabel Text property everything stays assigned.

    Чесноков

    N 1 Reply Last reply
    0
    • C Chesnokov Yuriy

      I use model view presenter approach for ASP.NET web site. The presentation part is compiled in separate class library where view contracts and presenters are defined:

      MyPresentation assembly
      IMyView
      {
      DisplayText(string text);
      }
      MyPresenter
      {
      public IMyView View { get; set; }
      public DisplayText()
      {
      string text = Generate();
      View.DisplayText(text);
      }
      }

      MyWebApplication assembly
      public partial class MyForm : System.Web.UI.Page, IMyView
      {
      public void DisplayText(string text)
      {
      this.myLabel.Text = text;
      }
      ...
      protected void myButton_Click(object sender, EventArgs e)
      {
      Presenter.DisplayText(); // calls this.DisplayText()
      }
      }

      However after stepping out of Presenter.DisplayText() Text property of myLabel becomes null again as though no assignment were done. By all means if you replace the only line in myButton click event with direct setting of myLabel Text property everything stays assigned.

      Чесноков

      N Offline
      N Offline
      n podbielski
      wrote on last edited by
      #2

      And what is doing method Generate()?

      No more Mister Nice Guy... >: |

      C 1 Reply Last reply
      0
      • N n podbielski

        And what is doing method Generate()?

        No more Mister Nice Guy... >: |

        C Offline
        C Offline
        Chesnokov Yuriy
        wrote on last edited by
        #3

        returns string of letters

        Чесноков

        N 1 Reply Last reply
        0
        • C Chesnokov Yuriy

          returns string of letters

          Чесноков

          N Offline
          N Offline
          n podbielski
          wrote on last edited by
          #4

          I am asking because I am trying to work out something. But... huh whatever. I would say that you just setting text in another instance.

          No more Mister Nice Guy... >: |

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups