11231 : Script manager is ambiguous in the namespace system.Web.UI

Question

I went into vb.net5 and started a new web site and tied doing the instructions for To create an ajax< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

enabled Gantt chart. The error is Script manager is ambiguous in the namespace system.Web.UI.

 

After this I tried adding it to my current  ajax aspx vb.net 2005 and got the same errors.  And can’t get the old versions in source safe.  The error is Script manager is ambiguous in the namespace system.Web.UI.  I think something got messed up in the .net framework or something.  Don’t know how to fix this.

Answer

My guess is that your web.config is messed up.

 

Best solution?

 

Create a new project drag an update panel to it (with the VS and ajax version you want).

Copy the content from that web.config to your actual project.

 

 

More details:

Maybe you have a row like this:

<add assembly=”System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″/>

 

And a row like this:

<add assembly=”System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″/>

 

In the web.config? Then VS does not know where to go for system.web.extensions…

 

 

11168 : How do I use a CSS file with the GTP.NET?

Question

How do I use a CSS file with the GTP.NET?

Answer

Normally you do not want to add a css of your own to change the styles of the grid since one is generated for you based on the settings of the CellLayouts. This way you can have almost the same view in WinForms and ASP.NET.

The class names of the cells is taken from the names of the used CellLayout. You can choose to use an External style sheet or a style sheet section in the rendered page.

This property comes into play: ExternalStyles, When setting ExternalStyles to true the css stylesheet is NOT embedded into the rendered html. Intstead you must add an attribute to the head section. You will also need to create the theganttstyles.css and you can do this by calling UpdateExternalStyles with the file name of your choice. If you leave ExternalStyles to false (default) you do not need this, but on the other hand ajax does not update the head section so under certain circumstances you can run into troubles using embedded styles. 

UpdateExternalStyles,  When setting ExternalStyles to true the css stylesheet is NOT embedded into the rendered html.

Typical scenario for when to create to the css file:
Gantt_ASP_Main.ExternalStyles=true; // You have decided to use external styles, this might be set in the object inspector already LoadMainProjectData(); // You fill the Gantt with data AND you probably create some CellLayouts format grid cells
if (!File.Exists(Page.MapPath(“GanttStyle.css”))) // If you have no need for dynamic styles, the file does not need to be written every time… Gantt_ASP_Main.UpdateExternalStyles(Page.MapPath(“GanttStyle.css”)); // This call reads the CellLayouts and create the css content, and saves the file.   

 

11229 : Resizing the TimeItem”s Region

Question

When the GanttRow.CollisionDetect and GanttRow.IncreaseRowHeightOnCollision properties are set to true, the TimeItems that are not in a collision-area are shown as filling the entire height of the now expanded row.
When trying to resize them using the suggested solution in Q10210, the drawing itself shows a regular sized TimeItem, but the text and all the events still apply to the old Region, which covers the entire height of the row.
How do I redefine the TimeItem’s Region so that I will have a regular-sized and regular-behaving TimeItem while still enjoing the benefits of showing the collisions on an increased row?

Answer

This is how to use the OnTimeItem_UserDrawBounds and  OnTimeItem_UserDraw together:

In the OnTimeItem_UserDraw event change the given Rect and Bounding  Region (make them as thin as you need)
Start with the rect and create a new region:
       e.Rect=rect;
       e.BoundingRegion = new Region(rect);

In the OnTimeItem_UserDrawBounds you must do the same(assign new  e.Rect and e.BoundingRegion), since this event Is fired when the  logic is finding out the size of the time item for other reasons  than drawing.

 

    private void buttonSetUpTestSizeOverride_Click(object sender, EventArgs e)
    {
      gantt1.OnTimeItem_UserDraw += new TimeItemEvent(gantt1_OnTimeItem_UserDraw);
      gantt1.OnTimeItem_UserDrawBounds += new TimeItemEvent(gantt1_OnTimeItem_UserDrawBounds);
      GridNode gn=new GridNode();
      gantt1.Grid.RootNodes.Insert(0,gn);
      GanttRow gr = GanttRow.FromGridNode(gn);
      TimeItem ti=gr.Layers[0].AddNewTimeItem();
      ti.Start=gantt1.DateScaler.StartTime.AddDays(5);
      ti.Stop=ti.Start.AddDays(10);
      ti.TimeItemLayout=ti.TimeItemLayout.Clone() as TimeItemLayout;
      ti.TimeItemLayout.TimeItemStyle=TimeItemStyle.User;
    }

    /// <summary>
    /// This event can help you override how a time item is perceived in the TimeItemFromXY (the active clickable area )
    /// </summary>
    void gantt1_OnTimeItem_UserDrawBounds(Gantt aGantt, TimeItemEventArgs e)
    {     
      GraphicsPath gp=new GraphicsPath();
      gp.AddEllipse(e.Rect);
      e.BoundingRegion=new Region(gp);
    }

    /// <summary>
    /// …and this event helps you draw something in that area.
    /// Note that the two areas can differ, its up to you, but it will a bit strange…
    /// </summary>
    void gantt1_OnTimeItem_UserDraw(Gantt aGantt, TimeItemEventArgs e)
    {
      GraphicsPath gp = new GraphicsPath();
      gp.AddEllipse(e.Rect);
      e.G.DrawPath(new Pen(Color.Blue),gp);     
    }

11228 : How can I choose which printer to use?

Question

 

Using the print facilities of your object I can just launch the print preview based on the current default printer and its configurations (like paper size, etc).< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

I wonder how can do to let the user to select which printer to use and to properly configure it before printing the gantt.

 

Answer

 

Stole this more or less from MSDN:

public void Printing(string printer) {
 
try {
    streamToPrint =
new StreamReader (filePath);
   
try {
      printFont =
new Font(“Arial”, 10);
      PrintDocument pd =
new PrintDocument();
      pd.PrintPage +=
new PrintPageEventHandler(pd_PrintPage);
     
// Specify the printer to use.
      pd.PrinterSettings.PrinterName = printer;

      if (pd.PrinterSettings.IsValid) {
         pd.Print();
      }
     
else {   
         MessageBox.Show(
“Printer is invalid.”);
      }
    }
   
finally {
      streamToPrint.Close();
    }
  }
 
catch(Exception ex) {
    MessageBox.Show(ex.Message);
  }
}

 

 

11126 : Bigger jumps on datescaler scrolling

Question

I would like to change the user scroll step. I want the user to take bigger steps in time when they press the datescaler scrollbuttons. How can I go about that?

Answer

One way to solve that is to implement the OnBeforeScaleOrSpanChange event and change the deault values.

    private void buttonSetUpBiggerJumpOnTimeScroll_Click(object sender, EventArgs e)
    {
      gantt1.DateScaler.OnBeforeScaleOrSpanChange += new BeforeScaleOrSpanChangeEventHandler(DateScaler_OnBeforeScaleOrSpanChange);
    }

    void DateScaler_OnBeforeScaleOrSpanChange(DateScaler dateScaler, BeforeScaleOrSpanChangeArgs e)
    {
      if (e.DateScalerChangeKind==DateScalerChangeKind.userpan)
      {
        TimeSpan defaultjumpsize=e.NewStartTime-gantt1.DateScaler.StartTime;
        // 4 times bigger jumps than default…
        e.NewStartTime = gantt1.DateScaler.StartTime + defaultjumpsize + defaultjumpsize + defaultjumpsize + defaultjumpsize;
        e.NewStopTime = gantt1.DateScaler.StopTime + defaultjumpsize + defaultjumpsize + defaultjumpsize + defaultjumpsize;
       
      }
    }

11150 : if I want to add attributes like mouseover for the time times how do I do that?

Question

< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

if I want to add attributes like mouseover for the time times how do I do that? Lets say for a button if I want to add a mouse over event in vb.net we can add like this

 

Button1.attributtes.add(“mouseover”,”mouseover()”)

 

I tried use ClientSideJavaScript_TimeItemInit event.

 

Is there any function avilable in plexityhide which i can add mouseover evenet for timeitem.

 

Answer

 

Sure, Go like this:

Gantt_ASP

.ClientSideJavaScript_TimeItemInit = “aImgElement.onmouseover=(function(event){alert(‘hello’);});\r\n”;

 

11143 : Is there a way to change the style of selected items?

Question

Is there a way to change the style of selected items?

Answer

The built in selection highlight is limited to the TimeItemLayout.SelectHandles=color, but if you want something more fancy it is really easy to implement the OnTimeItem_SelectionChanged event and simply change the TimeItemLayout if the time item is selected or de-selected.

The event is called both for selection and de-selection, so that you can set the timeitemlayout back to the original. Just check the e.TimeItem.Selected, true=selected false=de-selected.

11123 : I want to extend the grid columns so that they always fill the space in grid

Question

 

How can I automatically extend the grid column to use up all the space in the grid?

 

Answer

 

Implement the Grid.Resize event and do something like this:

 

< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

    void Grid_Resize(object sender, EventArgs e)

    {

      if (gantt1.Grid.Columns.SumWidth()<gantt1.Grid.Width)

      {

        gantt1.Grid.Columns.FirstVisibleColumn().Width+=gantt1.Grid.Width-gantt1.Grid.Columns.SumWidth();

      }

    }

11108 : Can the control drag the parent TimeItem to a different row and have all its associated sub items move with it?

Question

Can the control drag the parent TimeItem to a different row and have all its associated sub items move with it?

Answer

There is no property to set to do this automatically; you will need to react to an event and move child time items according to your rules.< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

In GTP.NET I would suggest to implement OnTimeItem_ChangeRow and in this event track down the child nodes by e.TimeItem.GanttRow.GridNode.SubNodes[0..x] and for each SubNode y do Gantt.GanttRowFromGridNode(y) then loop over the layers and timeItems and move them the way you need (or move the whole GridNode to a new parent if that is what you want).

 

11093 : Calculated columns in a databound Grid

Question

 

I am using the OnBeforeDSToCell event to format some data to be displayed in the grid.  But I want one of my columns to be calculated based on two other columns – how can I do this?

 

Answer

 

Since the columns are filled from 0 to n, you cannot read the x+1 column when handling OnBeforeDSToCell for column x.< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

But I suggest that you get your data from the datasource instead:

 

    void NodeDataConnect_OnBeforeDSToCell(NodeDataConnect aNodeDataConnect, CellAndDSArgs args)
    {
      if (args.Cell.Column.Index==theCellCalclulatedFromTwoOtherValues)
        args.Value=(args.CurrencyManagerListItem as DataRowView).Row[“Col1”].ToString()+(args.CurrencyManagerListItem as DataRowView).Row[“Col2”].ToString();
    }