Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Discussions

Juan Venter lesmemphis
  • POST through code behind in asp.net

    Dr Herbie said:
    lesmemphis said:
    *snip*

    ok, even though you're the competition, here's what I have used:

     

    System.Web.HttpContext.Current.Response.Clear();
    System.Web.HttpContext.Current.Response.Write("<html><head>");
    System.Web.HttpContext.Current.Response.Write(string.Format(CultureInfo.InvariantCulture, "</head><link text=\"text/css\" rel=\"stylesheet\" href=\"../../styles/styles.css\" />"));
    System.Web.HttpContext.Current.Response.Write(string.Format(CultureInfo.InvariantCulture, "<body onload=\"document.{0}.submit(); \">", "mainform"));
    System.Web.HttpContext.Current.Response.Write(string.Format(CultureInfo.InvariantCulture, "<body>"));
    System.Web.HttpContext.Current.Response.Write(string.Format(CultureInfo.InvariantCulture, "<form name=\"{0}\" method=\"{1}\" action=\"{2}\">", "mainform", "post", Url));
    for (int i = 0; i < Inputs.Keys.Count; i++)
    {
    	System.Web.HttpContext.Current.Response.Write(string.Format(CultureInfo.InvariantCulture, "<input name=\"{0}\" type=\"hidden\" value=\"{1}\">", Inputs.Keys[i], Inputs[Inputs.Keys[i]]));
    }
    System.Web.HttpContext.Current.Response.Write("</form>");
    System.Web.HttpContext.Current.Response.Write("</body></html>");
    

     

    Smiley

    Share and share alike -- I believe I picked this up somewhere on the internet, so it's only fair that I pass it on.

     

    Inputs is a NameValueCollection of the variables to add in the post.

    Url is the taget Url.

     

    Herbie

     

    Thanks for the help!!! Much appreciated! I'll try the code out and let you know if I managed!

     

    blowdart... I need to write  then post the script, because there is a lot that needs to be done before the site submits and redirects. It does work in IE. It's all those open source browsers that's giving me the headache! LOL

  • POST through code behind in asp.net

    I've been doing tests, and it turns out that my Post does not redirect when not in Internet Explorer. I need to post, because the payment gateway only receives the post and not querystring. Help! Perplexed

  • POST through code behind in asp.net

    Problem solved.

     

    I did not manage with HttpWebRequest, reason being I actually wanted to navigate to the page I was posting to. Maybe I just didn't know what I was doing! LOL

    Haven't tried WebClient, only got this reply after I solved my problem.

     

    Found a work-around though:

     

    private void submitForm()
        {
            System.Web.HttpContext.Current.Response.Write("<form name='newForm' target='_parent' method=post

                  action='https:// targetUrl'>");

            System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"p1\" value=\"{0}\">", p1TerminalID));

            System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"p2\" value=\"{0}\">", p2Reference));

            System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"p3\" value=\"{0}\">", p3Description));

            System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"p4\" value=\"{0}\">",

                   p4TransactionAmount));


            System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"p5\" value=\"{0}\">", p5Currency));


            System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"p11\" value=\"{0}\">",

                  p11ReceiptEmail));


            System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"Budget\" value=\"{0}\">",

                  isBudgetAllowed));


            System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"m_1\" value=\"{0}\">", m1BookID));

            System.Web.HttpContext.Current.Response.Write("</form>");
            System.Web.HttpContext.Current.Response.Write("</body>");

            Response.Write("<SCRIPT LANGUAGE='JavaScript'>document.forms[0].submit();</SCRIPT>");

    }

     

    Thanks for help though!

  • POST through code behind in asp.net

    I've got a booking that needs to send data to a payment gateway. I do not want to use query string, seeing as this is not a secure method of sending data. Currently I have a 2nd form with hidden fields and a submit button that sends the data via the form's POST action. Problem is this:

     

    I first need to execute a whole bunch of code before this form can be submitted. The ideal would be to be able to post all the data via code behind, alternatively to invoke the form submit through code behind. How do I do this? Perplexed

  • Asp mail in code behind

    figuerres said:
    figuerres said:
    *snip*

    if the server is remote and or if you need to auth before send then use this:

     

    SendEmail SM = new SendEmail();

    SM.ServerName = "smtp.domain.com";
             SM.Credential = new NetworkCredential(sendinguser@domain.com, "SecretPassword");

    replace server name and other values as needed.

    Thanks for the advice! Worked great!!!!

  • Asp mail in code behind

    Hey,

     

    I need to send info from a contact page to both administrator and also the client (if send copy checkbox is checked). It is an aspx page, and my code keeps bombing. Could someone look for a problem in my code? (also, maybe the problem lies with the server?)

     

    protected void ButtonSubmit_Click(object sender, EventArgs e)
            {
                if (Page.IsValid)//if captcha is entered correctly, this will be true
                {
                    bool error = false;
                    if (TextBoxSurname.Text == "")
                    {
                        LabelSurnameError.Visible = true;
                        error = true;
                    }
                    else
                    {
                        LabelSurnameError.Visible = false;
                    }
                    if (TextBoxEmail.Text == "")
                    {
                        LabelEmailError.Visible = true;
                        error = true;
                    }
                    else
                    {
                        LabelEmailError.Visible = false;
                    }
                    if (TextBoxEmail.Text != TextBoxConfirmEmail.Text)
                    {
                        LabelConfirmEmailError.Visible = true;
                        error = true;
                    }
                    else
                    {
                        LabelConfirmEmailError.Visible = false;
                    }
                    if (TextBoxEnquiry.Text == "")
                    {
                        LabelEnquiryError.Visible = true;
                        error = true;
                    }
                    else
                    {
                        LabelEnquiryError.Visible = false;
                    }
                    if (error == true)
                        return;

                    MailMessage msg = new MailMessage(TextBoxEmail.Text, "juan.venter@hotmail.com");
                    msg.Subject = "Backpackers portal Enquiry";

                    if (CheckBoxCopy.Checked)
                    {
                        msg.Bcc.Add(TextBoxEmail.Text);
                    }

                    msg.Body = "Submitted By: " + DropDownListTitle.Text + " " + TextBoxSurname.Text + "\n";

                    if (TextBoxFirstname.Text != "")
                    {
                        msg.Body += "Firstname : " + TextBoxFirstname.Text + "\n";
                    }
                    if (TextBoxContactNum.Text != "")
                    {
                        msg.Body += "Contact Number : " + TextBoxContactNum.Text + "\n";
                    }
                    if (TextBoxCell.Text != "")
                    {
                        msg.Body += "Cell Number : " + TextBoxCell.Text + "\n";
                    }

                    msg.Body += "Enquiry : " + TextBoxEnquiry.Text;

                    SmtpClient sm = new SmtpClient();
                    sm.Host = "196.22.134.22";
                    sm.Send(msg);

                    //Response.Write("<script>");
                    //Response.Write("Set myMail=CreateObject('CDO.Message')");
                    //Response.Write("myMail.Subject='Sending email with CDO'");
                    //Response.Write("myMail.From='juan.venter@hotmail.com'");
                    //Response.Write("myMail.To='juan@semper.co.za'");
                    //Response.Write("myMail.TextBody='This is a message.'");
                    //Response.Write("myMail.Send");
                    //Response.Write("set myMail=nothing");
                    //Response.Write("</script>");
                }
            }

     

    Thanks!!!! Angel

  • Horizontal window error

    Issue is officially resovled!!! Cool

     

    found my answer here:

     

    Popout menus not displayed in IE 8.0

  • Horizontal window error

    figuerres said:
    lesmemphis said:
    *snip*

    same thing ....

     

    are the other pages in folders under the main page ?

    /default.aspx

    /one/default.aspx

    /two/default.aspx

     

    if yes then look at the links to the css and js files and make sure they are valid.

     

    for example does the css and js  use ./file.css or does it use /file.css  to link the css or js files?

     

    ./file would work in the root folder but on in a sub-folder  as "." means current folder

     

    stuff like that.

    cool, thanks, will do!

  • Splash screen ​compatibili​ty issues

    W3bbo said:

    Well, let's start off with the fact splash-screens are a big "no-no" in the first place.

     

    Anyway, if something renders right in IE and not FF, then chances are you're doing something wrong (since FF implements the current specifications better than IE, in cases where IE renders differently it's usually when it deviates from or breaks with the specification)

     

    We'll need to see your code. I hope you're not using tables for layout.

    I'm not fond of splash-screen either. The boss wants to preview the site to select clients (although the site isn't done yet), and therefor instructed me to put a splash screen befon the wedsite loads stating the site isn't officially live yet.

     

    Code follows:

     

    I call this js file from my main:

     

    var splashpage=
    {
    splashenabled: 1,

    splashpageurl: "SubPages/SplashPage.aspx",

    enablefrequency: 0,

    autohidetimer: 4,

     

    launch:false,
    browserdetectstr: (window.opera&&window.getSelection) || (!window.opera && window.XMLHttpRequest), //current browser detect string to limit the script to be run in (Opera9 and other "modern" browsers)

    output:function()

    {
        document.write('<div id="slashpage" style="position: absolute; z-index: 100; color: white; background-color:white">')
        document.write('<iframe name="splashpage-iframe" src="about:blank" style="margin:0; padding:0; width:100%; height: 100%"></iframe>')
        this.splashpageref=document.getElementById("slashpage")
        this.splashiframeref=window.frames["splashpage-iframe"]
        this.splashiframeref.location.replace(this.splashpageurl)
        this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
        if (!/safari/i.test(navigator.userAgent))
        this.standardbody.style.overflow="hidden"
        this.splashpageref.style.left=0
        this.splashpageref.style.top=0
        this.splashpageref.style.width="100%"
        this.splashpageref.style.height="100%"
        this.moveuptimer=setInterval("window.scrollTo(0,0)", 50)
    },

     

    closeit:function()
    {
        clearInterval(this.moveuptimer)
        this.splashpageref.style.display="none"
        this.splashiframeref.location.replace("about:blank")
        this.standardbody.style.overflow="auto"
    },

     

    init:function()
    {
        if (this.enablefrequency==1){ //if frequency control turned on
            if (/sessiononly/i.test(this.displayfrequency)){ //if session only control
                if (this.getCookie(this.cookiename[0]+"_s")==null){ //if session cookie is empty
                    this.setCookie(this.cookiename[0]+"_s", "loaded")
                    this.launch=true
                }
            }
            else if (/day/i.test(this.displayfrequency)){ //if persistence control in days
                if (this.getCookie(this.cookiename[0])==null || parseInt(this.getCookie(this.cookiename[0]))!=parseInt(this.displayfrequency)){ //if persistent cookie is empty or admin has changed number of days to persist from that of the stored value (meaning, reset it)
                    this.setCookie(this.cookiename[0], parseInt(this.displayfrequency), parseInt(this.displayfrequency))
                    this.launch=true
                }
            }
        }
        else //else if enablefrequency is off
            this.launch=true
        if (this.launch){
            this.output()
            if (parseInt(this.autohidetimer)>0)
                setTimeout("splashpage.closeit()", parseInt(this.autohidetimer)*1000)
        }
    },

     

    getCookie:function(Name){
        var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
        if (document.cookie.match(re)) //if cookie found
            return document.cookie.match(re)[0].split("=")[1] //return its value
        return null
    },

     

    setCookie:function(name, value, days){
        var expireDate = new Date()
        //set "expstring" to either an explicit date (past or future)
        if (typeof days!="undefined"){ //if set persistent cookie
            var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))
            document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; "+splashpage.cookiename[1] //last portion sets cookie path
        }
    else //else if this is a session only cookie setting
        document.cookie = name+"="+value+"; "+splashpage.cookiename[1] //last portion sets cookie path
    }

    }

    if (splashpage.browserdetectstr && splashpage.splashenabled==1)
        splashpage.init()

     

     

    The splash-page (SubPages/SplashPage.aspx), is just a simple form with a label stating the site is in test phase and not live and a countdown timer. (redirecting in...) (the timer just counts down, it doesn't redirect, because it's already done in this js file.

     

    Thanks for the help! It is very much appreciated!

  • Horizontal window error

    lesmemphis said:
    figuerres said:
    *snip*

    Hey,

     

    thanks, I'll check into it and let you know if I resolved the issue.

    Wierd thing is that it works fine on all browsers in the home page. It's when i go to the subpages that it gets renered as blank white.

     

    I thought it could be a sintax issue when you render the url to the subpages (which is in their own folder), but I've tried different ways to call it and still get the same bug.