Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8330969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:17:04+00:00 2026-06-09T02:17:04+00:00

I am passing the page id component id and template id to a aspx

  • 0

I am passing the page id component id and template id to a aspx page as querystring with this java script:

var masterTabControl = $controls.getControl($("#MasterTabControl"),
                                            "Tridion.Controls.TabControl");
p.compPresTab = masterTabControl.getPage("ComponentPresentationsTab");
p.selectedComponentPresentation = p.compPresTab.getSelectedComponentPresentation();

p.selectedComp = p.selectedComponentPresentation.getComponentId();

window.open("http://" + location.hostname + ":path/test.aspx?pgId=" + pageId + 
            "&comId=" + p.selectedComponentPresentation.getComponentId() + 
            "&comTmpId=" + 
            p.selectedComponentPresentation.getComponentTemplateId(), 
            "myWindow", "status = 1, 
            toolbar=no,width=300,height=200,resizable=no,scrollbars=yes");

Now on the test.aspx page i am reading the id and with some additional information from the user i am saving it into a text file.

On a button click on popup test.aspx page i am saving it in text file:

sLogDetails = PageId + "| " + ComponentId + "|" + ComponentTemplateId + 
              "|" + text ;

//Move the contents to the temp file other than the existing one.
using (var sr = new StreamReader(permanentFile))
{
    using (var sw = new StreamWriter(@"" + tempFile , true))
    {
        string line;

        while ((line = sr.ReadLine()) != null)
        {
            string[] parts = line.Split('|');
            PageId = parts[0].Trim();
            ComponentId = parts[1].Trim();
            ComponentTemplateId = parts[2].Trim();

            //Check there exist same record already 
            if (SPageId != PageId.Trim() || SComponentId != ComponentId.Trim() 
                || SComponentTemplateId != ComponentTemplateId.Trim())
                sw.WriteLine(line);
        }

        //Delete the Permanent file & create permanent file from temporary file
        File.Delete(permanentFile);
        File.Move(tempFile, permanentFile);


        // Insert changes to the Permanent file
        using (StreamWriter w = File.AppendText(permanentFile))
        {
            // Close the writer and underlying file.
            w.WriteLine(sLogDetails);
            w.Flush();
            w.Close();
        }

If the id is already present in the text file then i am populating it in the text field on popup test.aspx page like :

using (StreamReader r = File.OpenText(strPath + "Log.txt"))
{
    string line;

    while ((line = r.ReadLine()) != null)
    {
        // Console.WriteLine(line);
        string[] parts = line.Split('|');
        PageId=parts[0].Trim();
        ComponentId = parts[1].Trim();
        ComponentTemplateId = parts[2].Trim();

        //If there exist a record populate the data fields
       if (SPageId == PageId.Trim() && SComponentId == ComponentId.Trim() 
           && SComponentTemplateId == ComponentTemplateId.Trim())
        {
            txtRuleName.Text = (string)parts[3];
        }

    }
    r.Close();
}

Now I am getting stuck here. When it’s populating in the text field, user can edit the text area in popup test.aspx page and on click of ok it will get saved in text file. And if user is closing the page window without “save & Close”, then the changes made by him in text field should not get saved in text file. It should revert back to old one.

Any idea how can i make it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T02:17:05+00:00Added an answer on June 9, 2026 at 2:17 am

    It is fairly difficult to respond to “something that didn’t happen”.

    So is there any way you can create a list of other ways that the user can exit that Window? With that list you can register the relevant event handlers (or override the relevant commands) and implement your roll back there.

    Alternatively you can consider making the change to the file in a temporary location from your popup. And then only commit it to your text file when the user clicks Save and Close.


    Note that his file-based approach will start failing when you scale out your Tridion GUI and Content Manager to run on multiple machines. In general you should be wary of storing things in files on a server, when you are working on enterprise level software. What is a single server now (and will always be a single server in your development environment) will turn into multiple servers at some point in the future at which time your solution will cause problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have web page which is passing a querystring parameter to page 2: <a
I'm passing query string parameter to .aspx page with 'Ñ' character in value. But
I call the jsp page with passing the parameter as array variable var textval1=new
i have placed a SqlDataSource component on my aspx page but while configuring the
Looking for advice on passing variables from page to page without using QueryString. The
If I redirect to a new page passing TempData to initialise the page it
I am passing a list to my scala page and I have a form
I'm passing a piece of HTML from my page to a flash movie, where
I am passing an object from one asp.net page to another. I'm encoding the
I am passing a string into a hidden field on the page and then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.