Click here to Skip to main content
15,916,949 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
Hello

this is how I work on the show so that my user, for example, they have upload a picture on the website.

I have done so here at my side

if (UploadSuccesBesked.UploadIndhold(1))
                {
                    PanelIndhold.Visible = true;
                    LiteralBesked.Text = "<div class='alert alert-success'><strong>Upload</strong> Succes du fik upload dit billede!</div>";
                }



the text which I have right here, I could well imagine to have in my class so I only have to right it somewhere. but over in my class I have done so here.

int load = 3;
        if (succes == 1)
        {
            HttpContext.Current.Response.AddHeader("REFRESH", load + ";URL=?opdater=true");
            return true;
        }


this is how I would like to order this text content into the class.

Know that I have written some things in Danish but you may ask into if you do not quite understand where I'm going?


EIDT:

My class

public class UploadSuccesBesked
{
    public static bool UploadIndhold(int succes)
    {
        int load = 3;
        if (succes == 2)
        {
//I would like to order this here text in here,
//"<div class='alert alert-success'>Upload Succes du fik opdater din adgangskode!</div>";
            HttpContext.Current.Response.AddHeader("REFRESH", load + ";URL=?opdater=true");
            return true;
        }
        else if (succes == 2)
        {
            HttpContext.Current.Response.AddHeader("REFRESH", load + ";URL=?opdater=false");
            return true;
        }
        //Det er hvis intet af det passer overhovedet!!
        return false;
    }
}
Posted
Updated 7-May-15 12:38pm
v2
Comments
Sergey Alexandrovich Kryukov 7-May-15 18:14pm    
Not clear. You did not show a single class. What does it mean "text content of the class"? "to order text content into the class"?
There are no such notions. Please explain things properly.
—SA
Jesper Petersen 7-May-15 18:30pm    
I add comment further down the page.
Sergey Alexandrovich Kryukov 7-May-15 18:34pm    
Please move it to the question. Still, you don't answer to my questions. And this is bad, unsupportable code anyway, using such immediate constants as your 1, 3, etc. is the anti-pattern called "magic numbers".
—SA
Jesper Petersen 7-May-15 18:38pm    
Now i have move its,
Sergey Alexandrovich Kryukov 7-May-15 18:41pm    
Good. Probably you will be able to answer my questions then. :-)
—SA

1 solution

So...lets try to clear this up...

You want to have
C#
public class UploadSuccesBesked
{
public property string Messages;
}

and then set that in your class and show on the page...right?

It is not clear if this is MVC or what?

If it is, then Message becomes part of the model and all you need is to refresh the view and show the dialog (which will contain @m.Message...

if this is ASP.NET then you add the message to some public variable (or Session), read it in javascript and call showMessageDiv (which is already on the page, just hidden)

it would go (something) like this:
CSS:
CSS
.hidden {display: none;}

HTML:
HTML
<div id="msg-dialog" class="alert alert-success hidden">Upload <span id="msg"></span>/pre>

<pre lang="Javascript">$("#msg").val("<%=your server variable%>");
#("#msg-dialog").show();


You could do the same directly manipulating hidden panel server side just by adding runat="server" to the div.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900