Refresh Master Page

New Contributor

Is there a quick easy way to tell the master page to refresh from a button?

Content is all changed, variables are session wide

Just need to refresh the master page for a button on a child page that redirects to itself. successfully, but the master page does not change.

 

The goal is to get the image location which is saved in session["Avatar"] to the master page.  If user logs out and back in, the image is update correctly, but I want to do it without the need to log in and out

 

 

                // Save the uploaded file to the server.
                strFilePath = strFolder + strUserName + "_" + strFileName;
                oFile.PostedFile.SaveAs(strFilePath);
                lblUploadResult.Text = strFileName + " has been successfully uploaded.";
                string varCS2 = ConfigurationManager.ConnectionStrings["csUserData"].ConnectionString;
                string strFileRename = strUserName + "_" + strFileName;
                string varSQL = "UPDATE UserData SET Avatar = '" + strFileRename + "' WHERE UserName = '" + strUserName + "'";
                Session["Avatar"] = strFileRename;
                SqlConnection cnn = new SqlConnection(varCS2);
                cnn.Open();
                try
                {
                    using (SqlCommand cmd = new SqlCommand(varSQL, cnn))
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    lblUploadResult.Text = strFileName + " has been successfully uploaded.";
                    lblUploadResult.Text = "Copy Error and send to Email address removed - " + strUserName + "failed due to error: " + ex.ToString();
                }
                cnn.Close();
                Response.Redirect(Request.RawUrl);
            }
            else
            {
                lblUploadResult.Text = "Click 'Browse' to select the file to upload.";
            }
            // Display the result of the upload.
            frmConfirmation.Visible = true;

 

0 Replies