Monday, 28 January 2013

Pass values from one domain to other domain


Page in Domain 1
protected void Button1_Click(object sender, EventArgs e)
{
    string remoteUrl = "http://localhost:54358/PostDataFromOneWebsiteToAnother/Page2_CS.aspx";
    string firstName = "Raghavendra";
    string lastName = "Aitha";
    ASCIIEncoding encoding = new ASCIIEncoding();
    string data = string.Format("FirstName={0}&LastName={1}", firstName, lastName);
    byte[] bytes = encoding.GetBytes(data);
    HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(remoteUrl);
    httpRequest.Method = "POST";
    httpRequest.ContentType = "application/x-www-form-urlencoded";
    httpRequest.ContentLength = bytes.Length;
    using (Stream stream = httpRequest.GetRequestStream())
    {
        stream.Write(bytes, 0, bytes.Length);
        stream.Close();
    }
}

 Page in Domain 2
protected void Page_Load(object sender, EventArgs e)
{
    if (Request.Form.Count > 0)
    {
        string firstName = Request.Form["FirstName"];
        string lastName = Request.Form["LastName"];
    }
}

Pass values from domain to other


One of the methods could be "Post" the page to the other page in different domain. and read data using request - response model.
Lets you have page1.aspx in domain1 and page2.aspx in domain2.
you habe to pass the data from page1 to page2.


Page1 -
<form id="frm" name="frm" method="post" runat="server" action="http://domain2/page2.aspx">
   <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
   <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
</form>
Now on a button click on this form you need to submit the form -
js -

function SubmitThis()
{
  document.frm.submit();
}
========================
now on page2 -
cs-
txt1 = Request["TextBox1"].ToString();
txt2 = Request["TextBox2"].ToString();

Thursday, 24 January 2013

Mouse over and Mouse out with CSS

Declare anchor tag
<a href="../UserPages/wpWelcome.aspx" id="aHome"  ><span>Home </span></a>

Write css for anchor tags(but careful that it will apply for all anchors)

a
{
    color: Blue;
}

a:hover
{
    font-weight: bold;
    text-decoration: underline;
    color: orange;
}

Menu Mouse over and out using jquery

decalre anchor tags in html or design page

<a href="../UserPages/wpWelcome.aspx" id="aHome" onmouseover="fnMouseOver(this)"
    onmouseout="fnMouseOut(this)"><span>Home </span></a>



Write Jquery Functions in Script Tags

function fnMouseOver(obj) {
    $(obj).css({ 'font-weight': 'bold', 'color': 'orange' });
}

function fnMouseOut(obj) {
    var address = $(location).attr('href');
    var href = $(obj).attr('href');
    if (href !== '#') {
        href = href.substring(13);
        if (address.indexOf(href) >= 0) {
        }
        else {
            $(obj).css({ 'font-weight': 'normal', 'color': 'blue' });
        }
    }
    else if (href === '#') {
        $(obj).css({ 'font-weight': 'normal', 'color': 'blue' });
    }
}