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

  • Home
  • SEARCH
  • 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 7976771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:59:54+00:00 2026-06-04T08:59:54+00:00

private void DisplayImages(string imageFile) { Image pImage = new Image(); pImage.ImageUrl = imageFile; this.Controls.Add(pImage);

  • 0
private void DisplayImages(string imageFile)
{
        Image pImage = new Image();
        pImage.ImageUrl =  imageFile;
        this.Controls.Add(pImage);

}

above is the current code but the image is not getting displayed and I want to check URL value. I have a javascript function that will check for URL and return the URL. All I need to do is assign the URL returned from javascript to the above image using what is called as POST. How can I achieve this in code-behind in above function?

Please suggest.

Update 1: I had forgot to add “this.Controls.Add(pImage);”. I have added above.

Update 2: I am creating Image control (As shown in the code) during onLoad of the page. The URL for this is usually longer and comes from an XML. I printed the URL value before assigning to image control.

Now for some reason, image doesn’t render in browser. Just now I found that even that URL when rendered in separate browser gives me HTTP 403. The person who built that URL and stored in XML tells me that I should use Javascript and do a POST by sending this URL. I need to know how I can do the javascript in the below code such that the image URL gets assigned after the POST method. Hope this clarifies.

Update 3: Below is the Javascript in the ASPX page.

    <script type="text/javascript">
        // Open URL in new window with a a post instead of the get
        function posturl(url) {
            alert("I am here");
            var qsBegin = url.indexOf("?");
            var qsPattern = new RegExp("[?&]([^=]*)=([^&]*)", "ig");
            var match = qsPattern.exec(url);
            var params = new Array();

            while (match != null) {
                // matched text: match[0]
                // match start: match.index
                // capturing group n: match[n]
                var matchID = match[1];
                if ( matchID.charAt(0) == "&" ) {
                    matchID = matchID.substr(1);
                }

                if ( params[match[1]] != null && !(params[match[1]] instanceof Array) ) {
                    var subArray = new Array();
                    subArray.push(params[match[1]]);
                    subArray.push(unescape(match[2]));
                    params[match[1]] = subArray;
                } else if ( params[match[1]] != null && params[match[1]] instanceof Array ) {
                    params[match[1]].push(unescape(match[2]));
                } else {
                    params[match[1]]=unescape(match[2]);
                }   
                match = qsPattern.exec(url);
            }

            var myForm = document.createElement("form");
            //myForm.setAttribute("target", "_blank");
            myForm.method="post" ;
            myForm.action = url.substring(0,qsBegin) ;
            for (var k in params) {
                var myInput;
                // Check for params with the same name.
                if ( params[k] instanceof Array ) {
                    for ( var i=0; i<params[k].length; i++ ) {
                        myInput = createFormInput(k, params[k][i]);
                        myForm.appendChild(myInput) ;
                    }
                } else {
                    myInput = createFormInput(k, params[k]);
                    myForm.appendChild(myInput);
                }
            }

            document.body.appendChild(myForm) ;
            myForm.submit() ;
            document.body.removeChild(myForm) ;
            //return "did you get what you wanted";
        }
</script>
  • 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-04T08:59:56+00:00Added an answer on June 4, 2026 at 8:59 am

    There is NO difference how do you get your URL and set it to the Image control, using javascript and posting back URL makes no sense, since you got that URL allready on server side and you should just set it to the Image control, assuming that URL is valid. First thing you should do is test is that URL valid, just paste it in the browser and see if it works, if not you should talk to that person that provides you that URL.

    btw. don’t create image control on the fly, create it in the markup and assign ImageUrl property in DisplayImages method, if you must create ImageControls dinamically do that in the OnInit.

    Update 3 comments :

    well, IMO this is insane, please no offense 🙂 but as I can see this javascript alters original URL that you get from XML, I think that best thing that you can do is to duplicate that Javascript code in c#, eg. do that same thing to URL only on server side with C#.

    Problem with this is that you are generating your page on server, that includes URL for image control, and after you generated whole page on server then javascript is executed and then is to late to change Url of image control. Maybe this post it to server aproach is good for some scenarios but surley not for yours.

    Another update

    Well Anirudh, after looking more to that javascript it seems that you are trying to use a image generating service and you must post parameters to their service and it would return URL for image generated based on params that you set in that URL, is that right ?

    If so you should really write that in the first place, do you see how much effort was needed to extract that information from you ? Please invest more effort in asking questions and it would be best to delete this question and ask another one but this time describe better what are you trying to do.

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

Sidebar

Related Questions

private void launchEventPanel(String title) { EventQueue.invokeLater(new Runnable(title) { public void run() { JFrame myFrame
private void mnuCustomerAdd_Click(object sender, EventArgs e) { CustomerForm frmCust = new CustomerForm(Add A New
private void Test(string param) { Thread.Sleep(OneDay); Submit(param); } This is console application. Is there
private void btnBrowserGo_Click(object sender, EventArgs e) { browser.Navigate(txtBrowserURL.Text); } The code above directs the
private void frmSearch_Load(object sender, EventArgs e) { // TODO: This line of code loads
private void sessionText() { try { System.IO.TextReader r = new System.IO.StreamReader(saved.txt); this.textBox1.Text = r.ReadLine();
private void SetAppData() { ArrayList alDiscoveredNodes = this.DiscoverNetworNodes(); //initializeViewDataTable will add colums to ViewDataTable
private void setActionViewListener(final String uri) { mediaButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v)
private void copyMB() { AssetManager assetManager = this.getResources().getAssets(); String[] files = null; try {
private void Draw(){ int width = Screen.PrimaryScreen.Bounds.Width; int height = Screen.PrimaryScreen.Bounds.Height; Bitmap image= new

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.