CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

MS SQL 2008 on ASP.NET Hosting



Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: NewsGroup Date Entered: 4/17/2007 9:06:15 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 18 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
Ramzy N.Ebeid
Asp.Net User
Same 2 UserControls in an ASPX page4/17/2007 9:06:15 AM

0/0

Dear Team

i am working with ASP.NET2.0, C#, AJAX, JavaScript

i have a usercontrol this usercontrol have an update panel + timer + GridView + javascript function that make cells of grid view blink
 

i have a aspx page and then i put inside it 2 usercontrols of that user control


i have a verystrange atitude which is the second user control only blinks and first one dosent

please advise what to do.


thank you

Jessica Cao - M
Asp.Net User
Re: Same 2 UserControls in an ASPX page4/19/2007 6:02:18 AM

0/0

Hi,

Would you please show me the source code? It would be helpful.

Thank you,

Jessica


Jessica Cao
Sincerely,
Microsoft Online Community Support


?Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ?
Ramzy N.Ebeid
Asp.Net User
Re: Same 2 UserControls in an ASPX page4/19/2007 9:49:22 AM

0/0

Dear sir

I will explain more to you.

After I did "this.cleintID" and it worked, but I found that it is not perfect.

I want tell you that this usercontrol 'X' contain an update panel + timer tick + gridview which is refreshed every 5 sec.
The idea is that everything is working very good even in multiple user controls from the same ID.

The problem was that, the javascript function, but I did make the "this.cleintID".

How dose it works, every 5 sec I hit the server and I get the new data as a dataset and I bind it on the grid view, and I add it to a view state because the next 5 sec I get the new data and then bind it the girdview1 and the bind the viewstate to the gridview2  and then from javascript I can make some comparison, which will make cells of gridview1 colored to green and Red, after 2 sec I call other javascript function  that reset all the colors.

If I run only 1 usercontrol then it is working very well,
If I run 2 usercontrols from the same name then it is not working good.

Please advise what to do.
please find
1 - all the HTML + JavaScript
2 - the method i call every 5 Sec.

This is the client side javascript:
<script language="javascript" type="text/javascript">
// all the scripts have to wait for the whole page to be loaded (including external files like js libraries)
if (window.addEventListener)
    window.addEventListener("load", PageOnLoad, false); // Mozilla, Netscape, Firefox
else
    window.attachEvent("onload", PageOnLoad); // IE
// this is called only the first time and NOT on AJAX updates
function PageOnLoad()
{
  Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoadedHandler<%=this.ClientID %>);
}
// this is called the first time AND on full postbacks AND on AJAX updates
function PageLoadedHandler<%=this.ClientID %>(sender, args)
{
    BlinkValuationViewCellsVV<%=this.ClientID %>();
}
function BlinkValuationViewCellsVV<%=this.ClientID %>()
{
    if (document.getElementById('<%=inputGridRowCount.ClientID%>').value == "0")
    {
        return;
    }
    if (document.getElementById('<%=inputGridRowCount2.ClientID%>').value == "0")
    {
        return;
    }
    var GV1 = document.getElementById('<%=GridView1.ClientID%>');
    var GV2 = document.getElementById('<%=GridView2.ClientID%>');
    //
    //alert(document.getElementById('<%=inputGridRowCount.ClientID%>').value);
    //alert(document.getElementById('<%=inputGridRowCount2.ClientID%>').value);
    //
    //return;
    if (GV1.rows[1].cells[1].innerHTML == "&nbsp;")
    {
        return;
    }
    //
//    alert(<%=this.ClientID %>)
    for (i = 1 ; i <= document.getElementById('<%=inputGridRowCount.ClientID%>').value ; i++)
    {
        var nGvRouterCode1 = GV1.rows[i].cells[0].innerHTML;
        var nGvRouterCode2 = GV2.rows[i].cells[0].innerHTML;
        //alert(nGvRouterCode1 + "  " +  nGvRouterCode2);
     
        if (nGvRouterCode1 == nGvRouterCode2)
        {
            var ihfMarketPrice = document.getElementById('<%=inputMarketPrice.ClientID%>').value;
            var ihfValuation = document.getElementById('<%=inputValuation.ClientID%>').value;
            var ihfGainLoss = document.getElementById('<%=inputGainLoss.ClientID%>').value;
            var ihfGainLossPer = document.getElementById('<%=inputGainLossPer.ClientID%>').value;
            //One
            if (ihfMarketPrice != "-1")
            {
                var nGvMarketPrice1 = GV1.rows[i].cells[ihfMarketPrice].innerHTML;
                var nGvMarketPrice2 = GV2.rows[i].cells[ihfMarketPrice].innerHTML;
               
                if (nGvMarketPrice1 > nGvMarketPrice2)
                {
                    alert(nGvMarketPrice1 +"    "+ nGvMarketPrice2);   
                    GV1.rows[i].cells[ihfMarketPrice].style.color = "black";
                    GV1.rows[i].cells[ihfMarketPrice].style.backgroundColor = "green";
                }
                if (nGvMarketPrice1 < nGvMarketPrice2)
                {
                    GV1.rows[i].cells[ihfMarketPrice].style.color = "black";
                    GV1.rows[i].cells[ihfMarketPrice].style.backgroundColor = "red";
                }
            }
            //Second
            if (ihfValuation != "-1")
            {
                var nGvValuation1 = GV1.rows[i].cells[ihfValuation].innerHTML;
                var nGvValuation2 = GV2.rows[i].cells[ihfValuation].innerHTML;           
                if (nGvValuation1 > nGvValuation2)
                {
                    GV1.rows[i].cells[ihfValuation].style.color = "black";
                    GV1.rows[i].cells[ihfValuation].style.backgroundColor = "green";
                }
                if (nGvValuation1 > nGvValuation2)
                {
                    GV1.rows[i].cells[ihfValuation].style.color = "black";
                    GV1.rows[i].cells[ihfValuation].style.backgroundColor = "red";
                }
            }
            //Third
            if (ihfGainLoss != "-1")
            {
                var nGvGainLoss1 = GV1.rows[i].cells[ihfGainLoss].innerHTML;
                var nGvGainLoss2 = GV2.rows[i].cells[ihfGainLoss].innerHTML;               
                if (nGvGainLoss1 > nGvGainLoss2)
                {
                    GV1.rows[i].cells[ihfGainLoss].style.color = "black";
                    GV1.rows[i].cells[ihfGainLoss].style.backgroundColor = "green";
                }
                if (nGvGainLoss1 < nGvGainLoss2)
                {
                    GV1.rows[i].cells[ihfGainLoss].style.color = "black";
                    GV1.rows[i].cells[ihfGainLoss].style.backgroundColor = "red";
                }
            }
            //Fourth
            if (ihfGainLossPer != "-1")
            {
                var nGvGainLossPer1 = GV1.rows[i].cells[ihfGainLossPer].innerHTML;
                var nGvGainLossPer2 = GV2.rows[i].cells[ihfGainLossPer].innerHTML;               
                if (nGvGainLossPer1 > nGvGainLossPer2)
                {
                    GV1.rows[i].cells[ihfGainLossPer].style.color = "black";
                    GV1.rows[i].cells[ihfGainLossPer].style.backgroundColor = "green";
                }
                if (nGvGainLossPer1 < nGvGainLossPer2)
                {
                    GV1.rows[i].cells[ihfGainLossPer].style.color = "black";
                    GV1.rows[i].cells[ihfGainLossPer].style.backgroundColor = "red";
                }
            }
        }
    }
    setTimeout("AfterValuationViewSleepVV<%=this.ClientID %>();", 2000);
}
function AfterValuationViewSleepVV<%=this.ClientID %>()
{
    var GV1 = document.getElementById('<%=GridView1.ClientID%>');
    var ihfMarketPrice = document.getElementById('<%=inputMarketPrice.ClientID%>').value;
    var ihfValuation = document.getElementById('<%=inputValuation.ClientID%>').value;
    var ihfGainLoss = document.getElementById('<%=inputGainLoss.ClientID%>').value;
    var ihfGainLossPer = document.getElementById('<%=inputGainLossPer.ClientID%>').value;
   
    for (i = 1 ; i <= document.getElementById('<%=inputGridRowCount.ClientID%>').value ; i++)
    {
        GV1.rows[i].cells[ihfMarketPrice].style.backgroundColor = "";
        GV1.rows[i].cells[ihfValuation].style.backgroundColor = "";
        GV1.rows[i].cells[ihfGainLoss].style.backgroundColor = "";
        GV1.rows[i].cells[ihfGainLossPer].style.backgroundColor = "";
        //
        var nGvMarketPrice1 = GV1.rows[i].cells[ihfMarketPrice].innerHTML;
        var nGvValuation1 = GV1.rows[i].cells[ihfValuation].innerHTML;
        var nGvGainLoss1 = GV1.rows[i].cells[ihfGainLoss].innerHTML;
        var nGvGainLossPer1 = GV1.rows[i].cells[ihfGainLossPer].innerHTML;
        //One       
        if (nGvMarketPrice1 > 0)
        {
            GV1.rows[i].cells[ihfMarketPrice].style.color = "green";
        }
        else if (nGvMarketPrice1 < 0)
        {
            GV1.rows[i].cells[ihfMarketPrice].style.color = "red";
        }
        //Two
        if (nGvValuation1 > 0)
        {
            GV1.rows[i].cells[ihfValuation].style.color = "green";
        }
        else if (nGvValuation1 < 0)
        {
            GV1.rows[i].cells[ihfValuation].style.color = "red";
        }
        //Third
        if (nGvGainLoss1 > 0)
        {
            GV1.rows[i].cells[ihfGainLoss].style.color = "green";
        }
        else if (nGvGainLoss1 < 0)
        {
            GV1.rows[i].cells[ihfGainLoss].style.color = "red";
        }
        //Fourth
        if (nGvGainLossPer1 > 0)
        {
            GV1.rows[i].cells[ihfGainLossPer].style.color = "green";
        }
        else if (nGvGainLossPer1 < 0)
        {
            GV1.rows[i].cells[ihfGainLossPer].style.color = "red";
        }       
    }
}
</script>
<table id="tMaster" runat="server">
    <tr>
        <td style="padding-left: 10px; font-weight: bold; font-size: 11pt; vertical-align: top; color: #cc0000; padding-top: 12px; height: 35px;" id="tdTitle" runat="server">
            </td>
    </tr>
    <tr>
        <td>
            &nbsp;
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <table>
                        <tr>
                            <td style="width: 100px">
                    <asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick" Enabled="False">
                    </asp:Timer>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 100px">
            <asp:GridView ID="GridView1" runat="server" AllowSorting="True" OnDataBound="GridView1_DataBound"
                OnRowDataBound="GridView1_RowDataBound" OnRowDeleting="GridView1_RowDeleting"
                OnSorting="GridView1_Sorting" ShowFooter="True" AutoGenerateColumns="False">
            </asp:GridView>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 100px">
           
            <input id="inputMarketPrice" type="hidden" runat="server" value="-1" /><input id="inputRowIndex" type="hidden" runat="server" /><input id="inputSelectedCode" type="hidden" runat="server" /><input id="inputGridRowCount2" type="hidden" runat="server" value="0" /><input id="inputGridRowCount" type="hidden" runat="server" value="0"/><input id="inputValuation" type="hidden" runat="server" value="-1"/><input id="inputGainLoss" type="hidden" runat="server" value="-1"/><input id="inputGainLossPer" type="hidden" runat="server" value="-1"/></td>
                        </tr>
                        <tr>
                            <td style="display:none">
            <asp:GridView ID="GridView2" runat="server">
            </asp:GridView>
                            </td>
                        </tr>
                    </table>
                    <br />
                </ContentTemplate>
            </asp:UpdatePanel>
        </td>
    </tr>
</table>

 

This is the method that I call every 5 Sec from C#:

public void LoadData(string strSortBy)
    {
        if (ViewState["_sPortfolioID" + this.ClientID.ToString()] == null)
        {
            return;
        }
        DataSet _dsMyPortfolio;
        _dsMyPortfolio = tradeService.GetPortfolioValuationView(Session["sUserName"].ToString(), Session["sPassword"].ToString(), Convert.ToUInt32(ViewState["_sPortfolioID" + this.ClientID.ToString()].ToString()));
        if (_dsMyPortfolio == null || _dsMyPortfolio.Tables[0].Rows.Count == 0)
        {
            this.DataSetNoRows();
        }
        else
        {
            if (this.GridView1.Columns.Count == 0)
            {
                for (int i = 0; i < _dsMyPortfolio.Tables[0].Columns.Count; i++)
                {
                    if (_dsMyPortfolio.Tables[0].Columns[i].ColumnName == "VVReutersCode")
                    {
                        BoundField bfNewField = new BoundField();
                        bfNewField.HeaderText = "Reuters Code";
                        bfNewField.DataField = "VVReutersCode";
                        bfNewField.SortExpression = "VVReutersCode";
                        bfNewField.DataFormatString = "";
                        bfNewField.HtmlEncode = false;
                        GridView1.Columns.Add(bfNewField);
                    }
                    else if (_dsMyPortfolio.Tables[0].Columns[i].ColumnName == "VVHolding")
                    {
                        BoundField bfNewField = new BoundField();
                        bfNewField.HeaderText = "Holding";
                        bfNewField.DataField = "VVHolding";
                        bfNewField.SortExpression = "VVHolding";
                        bfNewField.DataFormatString = "";
                        bfNewField.HtmlEncode = false;
                        GridView1.Columns.Add(bfNewField);
                    }
                    else if (_dsMyPortfolio.Tables[0].Columns[i].ColumnName == "VVAverageCost")
                    {
                        BoundField bfNewField = new BoundField();
                        bfNewField.HeaderText = "Average Cost";
                        bfNewField.DataField = "VVAverageCost";
                        bfNewField.SortExpression = "VVAverageCost";
                        bfNewField.DataFormatString = "{0:###,###,##0.00}";
                        bfNewField.HtmlEncode = false;
                        GridView1.Columns.Add(bfNewField);
                    }
                    else if (_dsMyPortfolio.Tables[0].Columns[i].ColumnName == "VVMarketPrice")
                    {
                        BoundField bfNewField = new BoundField();
                        bfNewField.HeaderText = "Market Price";
                        bfNewField.DataField = "VVMarketPrice";
                        bfNewField.SortExpression = "VVMarketPrice";
                        bfNewField.DataFormatString = "{0:###,###,##0.00}";
                        bfNewField.HtmlEncode = false;
                        GridView1.Columns.Add(bfNewField);
                        this.inputMarketPrice.Value = Convert.ToString(i);
                    }
                    else if (_dsMyPortfolio.Tables[0].Columns[i].ColumnName == "VVCostBasis")
                    {
                        BoundField bfNewField = new BoundField();
                        bfNewField.HeaderText = "Cost Basis";
                        bfNewField.DataField = "VVCostBasis";
                        bfNewField.SortExpression = "VVCostBasis";
                        bfNewField.DataFormatString = "{0:###,###,##0.00}";
                        bfNewField.HtmlEncode = false;
                        GridView1.Columns.Add(bfNewField);
                    }
                    else if (_dsMyPortfolio.Tables[0].Columns[i].ColumnName == "VVValuation")
                    {
                        BoundField bfNewField = new BoundField();
                        bfNewField.HeaderText = "Valuation";
                        bfNewField.DataField = "VVValuation";
                        bfNewField.SortExpression = "VVValuation";
                        bfNewField.DataFormatString = "{0:###,###,##0.00}";
                        bfNewField.HtmlEncode = false;
                        GridView1.Columns.Add(bfNewField);
                        this.inputValuation.Value = Convert.ToString(i);
                    }
                    else if (_dsMyPortfolio.Tables[0].Columns[i].ColumnName == "VVGainLoss")
                    {
                        BoundField bfNewField = new BoundField();
                        bfNewField.HeaderText = "Gain Loss";
                        bfNewField.DataField = "VVGainLoss";
                        bfNewField.SortExpression = "VVGainLoss";
                        bfNewField.DataFormatString = "{0:###,###,##0.00}";
                        bfNewField.HtmlEncode = false;
                        GridView1.Columns.Add(bfNewField);
                        this.inputGainLoss.Value = Convert.ToString(i);
                    }
                    else if (_dsMyPortfolio.Tables[0].Columns[i].ColumnName == "VVGainLossPercentage")
                    {
                        BoundField bfNewField = new BoundField();
                        bfNewField.HeaderText = "Gain Loss %";
                        bfNewField.DataField = "VVGainLossPercentage";
                        bfNewField.SortExpression = "VVGainLossPercentage";
                        bfNewField.DataFormatString = "{0:c}";
                        bfNewField.HtmlEncode = false;
                        GridView1.Columns.Add(bfNewField);
                        this.inputGainLossPer.Value = Convert.ToString(i);
                    }
                }
            }
            if (ViewState["vsValuationView" + this.ClientID.ToString()] != null)
            {
                dv = ((DataSet)ViewState["vsValuationView" + this.ClientID.ToString()]).Tables[0].DefaultView;
                this.inputGridRowCount2.Value = ((DataSet)ViewState["vsValuationView" + this.ClientID.ToString()]).Tables[0].Rows.Count.ToString();
                GridView2.DataSource = dv;               
                dv.Sort = strSortBy;
                GridView2.DataBind();
            }
            ViewState.Add("vsValuationView" + this.ClientID.ToString(), _dsMyPortfolio);
            this.inputGridRowCount.Value = _dsMyPortfolio.Tables[0].Rows.Count.ToString();
            dv = _dsMyPortfolio.Tables[0].DefaultView;
            GridView1.DataSource = dv;
            dv.Sort = strSortBy;
            GridView1.DataBind();
            if (this.Timer1.Enabled == false)
            {
                this.Timer1.Enabled = true;
                this.Timer1.Interval = 5000;
            }
        }
    }

thank you
please advise what to do.

3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Professional ASP.NET 3.5 in C and VB: In C# and VB Authors: Bill Evjen, Scott Hanselman, Devin Rader, Pages: 1704, Published: 2008
Pro ASP. Net 3. 5 Server Controls and AJAX Components Authors: Rob Cameron, Dale Michalk, Pages: 740, Published: 2008
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005
ASP.NET 2.0 Instant Results Authors: Imar Spaanjaars, Paul Wilton, Shawn Livermore, Pages: 456, Published: 2006
ASP.NET by Example Authors: Steven A. Smith, Pages: 527, Published: 2002
Programming Visual Basic 2005 Authors: Jesse Liberty, Pages: 548, Published: 2005
Pro ASP.NET 2.0 in C# 2005: Create Next-generation Web Applications with the Latest Version of Microsoft's Revolutionary Technology Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1426, Published: 2006
Professional ASP.NET 2.0 Server Control and Component Development Authors: Shahram Khosravi, Pages: 1186, Published: 2006
ASP.NET Developer's JumpStart Authors: Paul D. Sheriff, Ken Getz, Pages: 648, Published: 2002
Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006

Web:
Using two user controls on the same page? - Stack Overflow I have a user control in a master page and the same user control directly in the aspx. The user control in the master page works fine, but when I try the ...
hosting multiple user controls on the same aspx page : The ... Assume UserControl1 is master list and UserControl 2 is details list. ... Marked as Answer. Re: hosting multiple user controls on the same aspx page ...
David Ebbo's blog : Using User Controls as Page Templates in ... Nov 25, 2008 ... And finally, it loads the user control using the exact same steps as above. ... .aspx?table=Products&action=Edit&ProductID=2">Test page that ...
Ajax confirmButton Extender not work well inside usercontrol and ... 12-15-2008, 2:52 AM. Contact ... If the TargetControl needs to point the control in main page or you need define TargetControl ... I shift to aspx pages for create my tab pages and try same work to do . that confirmation ...
Passing Values between User Controls and ASPX Page Dec 22, 2007 ... Multiple Silverlight User Controls on aspx page ... NET Part 2: Inheritance, Abstraction, & Polymorphism .... What changes do I need to make in my c# user control so I can read this value from the same web page. ...
Centering Various Size XAML User Controls within the same ASPX ... Dec 15, 2008 ... 12-11-2008 2:39 AM. Centering Various Size XAML User Controls within the same ASPX page. Reply Contact. Let's say you have this in your aspx ...
Adding multiple Silverlight user controls on aspx || DotNetMind ... Wednesday, July 2, 2008. Sometimes we have requirement of adding multiple Silverlight UserControls over same ASP.NET web page (aspx). ...
CodeProject: ASP.NET User Controls - Notify One Control Of Changes ... All the items: controls, master page and aspx page are within the same ... so basically we end up with 2 user controls but they raise the same event, ...
WDVL: User Controls - Page 2 The user control appears in each example page to demonstrate how the use of a user control ... Control Client
Problem w/ Validation in UserControl with 2 controls on the same p Talk about Problem w/ Validation in UserControl with 2 controls on the ... I've then created a Default.aspx page and added the following ...




Search This Site:










vs 2005 application works in asp.net development server, but not in iis5.1

wildcard

visual studio 2005 - avp.exe appears in solution explorer

play sound upon compile completion

error when checking sources in and out of source safe.

debug error

no xml documentation for websites in vs2005?

vs problem while opening any website in vb.net environment mode

transfer asp.net website from one computer to another

user controls in tables: design view?

vs install configuration

refreshing folder information for the web

setup & deployment??

visual studio too slow for windows app than asp.net app

user control properties in designer

access classes stored in separate directory from aspx.cs page

share resouces across projects

problem connecting to another server in server explorer

intellisense and custom controls

i can get to design view (source view & design view)

intellisense on the first word

new help system in vs2005.

disable id for servercontrols

getting set up

debugging non-managed code on visual studio.net

package load failure

studio to sourcesafe 2005 upload error on large files

extracting data from sqldatasource

show all files

how to restore ie as default browser after uninstalling the mozilla firefox.

  Privacy | Contact Us
All Times Are GMT