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. Passing data between asp pages and Message Queuing

Passing data between asp pages and Message Queuing

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdesigndata-structuresquestion
3 Posts 3 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.
  • D Offline
    D Offline
    DELETEUSER
    wrote on last edited by
    #1

    Languages – ASP.NET and C# I’m reading contents from Microsoft Message Queue (MSMQ) and displaying them in a dynamically generated table over the web page. The table is as show below Message Name Message ID ----------------------------------------------------------- Test Message 1 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8204 Test Message 2 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8205 Test Message 3 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8206 Test Message 4 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8207 Test Message 5 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8208 Now I want to create hyperlinks to messages in the queue i.e. messages in the first column of the table. The requirement is that when a user clicks on the hyperlink i.e. “Test Message (Number)” he should be able to see details like userid, time, etc. about that particular message in a new webform and at the bottom of that new webform should be a button control to delete the message from the queue. There are two .aspx files. Webform1.aspx - It has all the code to read from the MSMQ, create table and link to webform2. Webform2.aspx – It should have details of just ONE particular message which was clicked by the user in WebFrom1. I’m able to create table and generate link from weform1 to webform2 for the particular message. But I’m not able to proceed from there. How do I Pass the message name from webform1 to webform2, so that webform2 can retrieve the details about the particular message and delete it. Code for webform1 is as below ------------------------------- public class WebForm1 : System.Web.UI.Page { protected System.Web.UI.WebControls.Table Table1; private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here int rowCount = 0; MessageQueue sthQ = new MessageQueue(".\\Private$\\Sth"); MessageEnumerator sthEnum = sthQ.GetMessageEnumerator(); sthEnum.Reset(); while(sthEnum.MoveNext()) { TableGen(rowCount, sthEnum.Current.Label, sthEnum.Current.Id); rowCount++; } } private void TableGen(int rowCount, string msgLabel, string msgId) { for (int j= (rowCount); j<(rowCount+1); j++) { TableRow r = new TableRow(); TableCell c = new TableCell(); c.Controls.Add(new LiteralControl("" + msgLabel)); r.Cells.Add(c); TableCell c2 = new TableCell(); c2.Controls.Add(new LiteralControl(msgId)); r.Cells.Add(c2); Table

    J A 2 Replies Last reply
    0
    • D DELETEUSER

      Languages – ASP.NET and C# I’m reading contents from Microsoft Message Queue (MSMQ) and displaying them in a dynamically generated table over the web page. The table is as show below Message Name Message ID ----------------------------------------------------------- Test Message 1 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8204 Test Message 2 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8205 Test Message 3 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8206 Test Message 4 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8207 Test Message 5 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8208 Now I want to create hyperlinks to messages in the queue i.e. messages in the first column of the table. The requirement is that when a user clicks on the hyperlink i.e. “Test Message (Number)” he should be able to see details like userid, time, etc. about that particular message in a new webform and at the bottom of that new webform should be a button control to delete the message from the queue. There are two .aspx files. Webform1.aspx - It has all the code to read from the MSMQ, create table and link to webform2. Webform2.aspx – It should have details of just ONE particular message which was clicked by the user in WebFrom1. I’m able to create table and generate link from weform1 to webform2 for the particular message. But I’m not able to proceed from there. How do I Pass the message name from webform1 to webform2, so that webform2 can retrieve the details about the particular message and delete it. Code for webform1 is as below ------------------------------- public class WebForm1 : System.Web.UI.Page { protected System.Web.UI.WebControls.Table Table1; private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here int rowCount = 0; MessageQueue sthQ = new MessageQueue(".\\Private$\\Sth"); MessageEnumerator sthEnum = sthQ.GetMessageEnumerator(); sthEnum.Reset(); while(sthEnum.MoveNext()) { TableGen(rowCount, sthEnum.Current.Label, sthEnum.Current.Id); rowCount++; } } private void TableGen(int rowCount, string msgLabel, string msgId) { for (int j= (rowCount); j<(rowCount+1); j++) { TableRow r = new TableRow(); TableCell c = new TableCell(); c.Controls.Add(new LiteralControl("" + msgLabel)); r.Cells.Add(c); TableCell c2 = new TableCell(); c2.Controls.Add(new LiteralControl(msgId)); r.Cells.Add(c2); Table

      J Offline
      J Offline
      Jesse Squire
      wrote on last edited by
      #2

      If you are passing data between two pages, typically it is done by either using the Session object as intermediate storage, or by using a querystring. If neither of those is to your liking, you can create a public property on the first form and access it through the HttpContext.Handler object from the second form. The caveat here is that in order to use this mehtod, you have to be moving from page to page using Server.Transfer. Assuming that I have two pages, WebForm1 and WebForm2, the code for WebForm2 would look something like:

      private void Page_Load(object sender, System.EventArgs ea)

      {

      WebForm1 firstForm = HttpContext.Current.Handler as WebForm1;

      string messageId = null;

      if (firstForm != null)

      {

      messageId = firstForm.MessageId;

      }

      }

      However, I have to ask... are you sure that using two pages is the right way to go? In my opinion, you'd be better off turning WebForm2 into a user control. WebForm1 could then host WebForm2 and manipulate its methods/properties to retrieve and display the message details. Far less needless jumping around. Hope that helps. :) --Jesse

      1 Reply Last reply
      0
      • D DELETEUSER

        Languages – ASP.NET and C# I’m reading contents from Microsoft Message Queue (MSMQ) and displaying them in a dynamically generated table over the web page. The table is as show below Message Name Message ID ----------------------------------------------------------- Test Message 1 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8204 Test Message 2 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8205 Test Message 3 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8206 Test Message 4 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8207 Test Message 5 dde6b7aa-77e6-46be-bd98-f4e67e7e53ec\8208 Now I want to create hyperlinks to messages in the queue i.e. messages in the first column of the table. The requirement is that when a user clicks on the hyperlink i.e. “Test Message (Number)” he should be able to see details like userid, time, etc. about that particular message in a new webform and at the bottom of that new webform should be a button control to delete the message from the queue. There are two .aspx files. Webform1.aspx - It has all the code to read from the MSMQ, create table and link to webform2. Webform2.aspx – It should have details of just ONE particular message which was clicked by the user in WebFrom1. I’m able to create table and generate link from weform1 to webform2 for the particular message. But I’m not able to proceed from there. How do I Pass the message name from webform1 to webform2, so that webform2 can retrieve the details about the particular message and delete it. Code for webform1 is as below ------------------------------- public class WebForm1 : System.Web.UI.Page { protected System.Web.UI.WebControls.Table Table1; private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here int rowCount = 0; MessageQueue sthQ = new MessageQueue(".\\Private$\\Sth"); MessageEnumerator sthEnum = sthQ.GetMessageEnumerator(); sthEnum.Reset(); while(sthEnum.MoveNext()) { TableGen(rowCount, sthEnum.Current.Label, sthEnum.Current.Id); rowCount++; } } private void TableGen(int rowCount, string msgLabel, string msgId) { for (int j= (rowCount); j<(rowCount+1); j++) { TableRow r = new TableRow(); TableCell c = new TableCell(); c.Controls.Add(new LiteralControl("" + msgLabel)); r.Cells.Add(c); TableCell c2 = new TableCell(); c2.Controls.Add(new LiteralControl(msgId)); r.Cells.Add(c2); Table

        A Offline
        A Offline
        Alvaro Mendez
        wrote on last edited by
        #3

        Jesee gave you an excellent reply. However, I will say that my preferred method is to pass the information using the QueryString. In other words, set up your links to the second page like this: Webform2.aspx?messageID=123 Then inside Webform2 you can retrieve the value by using Request["messageID"]. Regards, Alvaro


        You know what they say about arguing over the Internet...

        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