Adeesanan Siva
Adeesanan Siva

Reputation: 43

How to display a div inside asp.net pageload

I'm trying to visible a div within aspx.cs C# file.here i'm using stored procedure to get the product list with prices.So i defined a div call sizemenu in the aspx page.How can i visible this within the particular function. is there any possible ways?

        Product product = new Product();
        product.Id =Convert.ToInt64(labl.Text);

        Hashtable parameterList = new Hashtable();
        parameterList.Add("saleId", index.saleid.Id);//sale id
        parameterList.Add("productId", product.Id);
        parameterList.Add("productSizeId", null);
        parameterList.Add("costPrice", null);
        parameterList.Add("salesPrice", null);
        //parameterList.Add("offerDetailId", null);
        parameterList.Add("offerFound", -1);
        parameterList.Add("currentDate", DateTimeUtil.GetFormattedString(((Sale)index.saleid).Date.Date));
        parameterList.Add("currentTime", DateTimeUtil.GetFormatedTimeString(Convert.ToDateTime(((Sale)index.saleid).Time)));
        parameterList.Add("day", Const.GetDay(((Sale)index.saleid).Date.DayOfWeek));
        parameterList.Add("productSizePointValue", null);
        parameterList.Add("isOfferUser", "False");
        parameterList.Add("recipeSelection", null);
        psList.SelectUsingSP(Global.sess, "SqlProInsertProductSizeToSale", parameterList);


        if (psList.Count == 0)
        {

        }
        else if (psList.Count == 1)
        {

        }
        else if (psList.Count > 1)
        {

           //want to display the div here   
        }

Upvotes: 0

Views: 1259

Answers (3)

Tummala Krishna Kishore
Tummala Krishna Kishore

Reputation: 8271

In your aspx Page for the div which you want to show it in the cs code behind.. make sure you add Id for the div and also another attribute runat="server" with that attribute only you can able to find the div id in code behind

Aspx Page

<div id="dvtoshow" runat="server" visible="false"></div>

In code Behind

if (psList.Count == 0)
        {

        }
        else if (psList.Count == 1)
        {

        }
        else if (psList.Count > 1)
        {
           dvtoshow.visible=true;
           //dvtoshow.innerHtml="your Text";

        }

Upvotes: 1

Rajshee Turakhia
Rajshee Turakhia

Reputation: 274

Take Div in .aspx page

  <div  id="divdisplay" runat="server" visible="false">
    //write your code//or html code
  </div>

in aspx.cs File

divdisplay.visible=false;
 if (psList.Count == 0)
        {

        }
        else if (psList.Count == 1)
        {

        }
        else if (psList.Count > 1)
        {
           divdisplay.visible=true;
           //divdisplay.innerHtml="vcxcvcxvcbvc.......";
           //want to bind html  div from code Behind
        }

above code helps you to make it working.

Upvotes: 0

Dirty Developer
Dirty Developer

Reputation: 562

yourdivid.style.add("display",""); //to show
yourdivid.style.add("display","none"); //to hide

Upvotes: 0

Related Questions