Thursday, January 31, 2013

How to make a space in a HTML list

this is how I did it

.space{ margin-bottom :50px;}


<li><i>a</i></li>
<li class ="space"><i>b</i></li>
<li><i> </i></li>

Wednesday, January 30, 2013

Compiler questions

let's say you had in a class overloaded procedures thus


   protected void click(object o)
        {

        }

        protected void click(string  o)
        {

        }
 and code thus

       protected void Button8_Click(object sender, EventArgs e)
        {
            string s = "fdgdfg";
            click(s);
            click(sender);
        }

would it compile and why?

Monday, January 28, 2013

Asp.net radio buttons

if you have a page thus


      <p>
          <asp:RadioButton GroupName ="tt" ID="RadioButton1" runat="server"  Checked="true" />
            <asp:RadioButton  GroupName ="tt" ID="RadioButton2" runat="server" />
              <asp:RadioButton  GroupName ="tt" ID="RadioButton3" runat="server" />
      </p>
      <asp:Button ID="Button7" runat="server" Text="radio"
          onclick="Button7_Click" />

and code thus:
   protected void Button7_Click(object sender, EventArgs e)
        {
           // this.RadioButton2.Checked = false;
            this.RadioButton1.Checked = true;
        }

and you you select the 2nd radio button and click button7 - what will happen?


since the values are set on load - the button code will do nothing because you can't have to radio buttons selected.



Friday, January 25, 2013

easy way to open docs from asp.net website

create a asp.net page and have on the pageload


            FileInfo fi = new FileInfo(Session["DocName"].ToString());
            if (!fi.Exists)
                return;

            Response.ClearContent();
            Response.ClearHeaders();
            Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
            Response.ContentType = "application/download";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + fi.Name);
            Response.AddHeader("Content-Length", fi.Length.ToString());
            Response.WriteFile(Session["DocName"].ToString());
            Response.End();



on your asp page have code thus

         Session["DocName"] = @"c:\blah\blah.xlsx";
            string iframeID = "iframe_contentview";
            string iframe = string.Format("<iframe id=\"{0}\" src=\"{1}\" style=\"display:none\"></iframe>", iframeID, "doc.aspx");
            ClientScript.RegisterStartupScript(GetType(), iframeID, iframe); 


and that's it 


presto!