Creating Dynamic Hotspots in an ASP.net imagemap - asp.net

I need the ability to create a dynamic number of hotspots in an imagemap
the pseudo code for what I want to do is below:
Protected Sub AddHotSpot()
Dim r1 New RectangleHotSpot
For Each Item as datarow in dataset
r1.HotSpotMode = HotSpotMode.PostBack
r1.PostBackValue = "HotSpot 1"
r1.AlternateText = "HotSpot 1"
r1.Top = Item.Top
r1.Left = Item.Left
r1.Bottom = Item.Bottom
r1.Right = Item.Right
Next
think of r1 as some form of dynamic construct

Figured out how to perform this. I had to make the object above part of an array list then add each object to the array

Related

How to create multi items/records or save item/record array at one time in client script file

I want to create multiple records at the same time using client script. This is what I'm doing:
var ceateDatasource = app.datasources.Reservation.modes.create;
var newItem = ceateDatasource.item;
newItem.User = user; //'eric'
newItem.Description = description; //'000'
newItem.Location_Lab_fk = lab.value.Id; //'T'
newItem.Area_fk = area.value.Id; //'L'
newItem.Equipment_fk = equipment.value.Id; //'S'
for(var i = 0 ; i < 3; i ++) {
newItem.Start_Date = startDate;
newItem.Start_Hours = '03';
newItem.Start_Minutes = '00';
newItem.End_Date = startDate;
newItem.End_Hours = '23';
newItem.End_Minutes = '30';
// Create the new item
ceateDatasource.createItem();
}
But the result I'm getting is this one:
The three records are created but the only the first one has data. The other two records have empty values on their fields. How can I achieve this?
Thanks.
Update(2019-3-27):
I was able to make it work by putting everything inside the for loop block. However, I have another question.
Is there any method like the below sample code?
var recordData = [Data1, Data2, Data3]
var ceateDatasource;
var newItem = new Array(recordData.length) ;
for(var i = 0 ; i < recordData.length; i ++) {
ceateDatasource = app.datasources.Reservation.modes.create;
newItem[i] = ceateDatasource.item;
newItem[i].User = recordData[i].user;
newItem[i].Description = recordData[i].Description;
newItem[i].Location_Lab_fk = recordData[i].Location_Lab_fk;
newItem[i].Area_fk = recordData[i].Area_fk;
newItem[i].Equipment_fk = recordData[i].Equipment_fk;
newItem[i].Start_Date = recordData[i].Start_Date;
newItem[i].Start_Hours = recordData[i].Start_Hours;
newItem[i].Start_Minutes = recordData[i].Start_Minutes;
newItem[i].End_Date = recordData[i].End_Date;
newItem[i].End_Hours = recordData[i].End_Hours;
newItem[i].End_Minutes = recordData[i].End_Minutes;
}
// Create the new item
ceateDatasource.createItem();
First, it prepares an array 'newItem' and only calls 'ceateDatasource.createItem()' one time to save all new records(or items).
I try to use this method, but it only saves the last record 'newItem[3]'.
I need to write a callback function in 'ceateDatasource.createItem()' but Google App Maker always show a warning "Don't make functions within a loop". So, are there any methods to call 'createItem()' one time to save several records? Or are there some functions like 'array.push' which can be used?
Thanks.
As per AppMaker's official documentation:
A create datasource is a datasource used to create items in a particular data source. Its item property is always populated by a draft item which can be bound to or set programmatically.
What you are trying to do is create three items off the same draft item. That why you see the result you get. If you want to create multiple items, you need to create a draft item for each one, hence all you need to do is put all your code inside the for loop.
for(var i = 0 ; i < 3; i ++) {
var ceateDatasource = app.datasources.Reservation.modes.create;
var newItem = ceateDatasource.item;
newItem.User = user; //'eric'
newItem.Description = description; //'000'
newItem.Location_Lab_fk = lab.value.Id; //'T'
newItem.Area_fk = area.value.Id; //'L'
newItem.Equipment_fk = equipment.value.Id; //'S'
newItem.Start_Date = startDate;
newItem.Start_Hours = '03';
newItem.Start_Minutes = '00';
newItem.End_Date = startDate;
newItem.End_Hours = '23';
newItem.End_Minutes = '30';
// Create the new item
ceateDatasource.createItem();
}
If you want to save several records at the same time using client script, then what you are looking for is the Manual Save Mode. So all you have to do is go to your model's datasource and click on the checkbox "Manual Save Mode".
Then use the same code as above. The only difference is that in order to persist the changes to the server, you need to explicitly save changes. So all you have to do is add the following after the for loop block:
app.datasources.Reservation.saveChanges(function(){
//TODO: Callback handler
});

How to add field to a Shapefile using DotSpatial?

I tried searching the web to find a sample of showing how to add a Field to attribute table of an existing shapefile. For example I have a Shapefile at
C://data/Streets.shp
and need to add two field L_CITY and R_CITY both text and 50 characters limit. How can I do this in DotSpatial?
The first thing you need to do is add a reference to System.Data. Otherwise, the type definition for the DataTable is not available and it may not be obvious what you can do to modify the schema.
Then you can use standard DataTable programming like the following code:
public void AddFieldExample()
{
IFeatureSet fs = FeatureSet.OpenFile("C:\\YourShapefile.shp");
DataTable table = fs.DataTable;
DataColumn lCity = table.Columns.Add("L_CITY");
lCity.MaxLength = 50;
DataColumn rCity = table.Columns.Add("R_CITY");
rCity.MaxLength = 50;
}

change row colors in a specific OutlookGroupBy group in UltraGrid in VB.net

I am using an ultragrid and inside i have values that i load into a datatable from a database. In my grid i group the rows into groups with OutlookGroupBy code. My rows in the grid are in two categories. The Priority 1 and 0. I want when the data are loaded the rows that are in priority 1 to get color red, and the others in priority 0 to be in normal color.
I use the ultragrid pro grammatically so i didnt use any of its features in the editor.
here is how i initialize my grid and how i load from database from another class:
Dim dt As DataTable = Nothing
Timer1.Enabled = True
UltraGrid1.DataSource = Nothing
Generic.openOrders(dt)
UltraGrid1.DataSource = dt
Dim band As Infragistics.Win.UltraWinGrid.UltraGridBand = UltraGrid1.DisplayLayout.Bands(0)
UltraGrid1.DisplayLayout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy
band.SortedColumns.Add(band.Columns("PRIORITY"), True, True)
band.SortedColumns.Add(band.Columns("ORDERID"), False, True)
band.SortedColumns.Add(band.Columns("ORDERTIME"), False, True)
anyone has any idea of how can i change the row color into the priority 1 subrows??
You can try with this approach:
First you need to subscribe the event InitializeRow, so add this by the designer or by code (eg. in Form_Load or before setting the DataSource of the grid)
grd.InitializeRow += new InitializeRowEventHandler(grd_InitializeRow);
then, in the event, write code like this
private void grd_InitializeRow(object sender, InitializeRowEventArgs e)
{
if(e.Row.Band.Index == 1)
{
if(Convert.ToInt32(e.Row.Cells["PRIORITY"].Value) == 1)
e.Row.Appearance.BackColor = Color.LightGreen;
}
}
Keep in mind that if you have set CellAppearance they will have precedence on RowAppearance and, if you have many rows it is better to initialize an Appearance object, store it in the grid.DisplayLayout.Appearances collection and reuse the same object for every row involved.
Moreover, always with the aim of improving the performance, to get the cell value it is better to use the GetCellValue method of the row. This will avoid the creation of the a full Cell object just to retrieve its value. Things are a bit more complicated because you need an UltraGridColumn and not just the name of the column, but in the InitializeRow event, fired for each row, this is little price to pay.
private void grd_InitializeRow(object sender, InitializeRowEventArgs e)
{
if(e.Row.Band.Index == 1)
{
UltraGridColumn priorityColumn = e.Row.Band.Columns["PRIORITY"];
if(Convert.ToInt32(e.Row.GetCellValue(priorityColumn)) == 1)
e.Row.Appearance.BackColor = Color.LightGreen;
}
}
EDIT: The same code in VB.NET
....
AddHandler grd.InitializeRow, AddressOf Me.grd_InitializeRow
....
Private Sub grd_InitializeRow(sender As System.Object, e As InitializeRowEventArgs)
If e.Row.Band.Index = 1 Then
Dim priorityCol As UltraGridColumn = e.Row.Band.Columns("PRIORITY")
If Convert.ToInt32(e.Row.GetCellValue(priorityCol)) = 1 Then
e.Row.Appearance.BackColor = Color.LightGreen
End If
End If
End Sub
Also, the use the UltraGridColumn class, you need to add at the start of file
Imports Infragistics.Win.UltraWinGrid

Finding Dynamic Control (Accordion Pane)

I'm using the code below to create dynamic panes in an accordion control. Info is read from a data set and the controls are generated based on that info. I'm now stuck when it comes to finding these controls. When a user clicks a button I need to loop through all the controls and get the information inside the textboxes... but all I really need to know is how to call the darn things!
Do Until b = 0
holder = ds.Tables(0).Rows(i).Item("Issue" & z).ToString
If holder <> "" Then
lblTitle = New Label()
txtContent = New TextBox()
lblTitle.Text = "Issue" & z & " " & ds.Tables(0).Rows(i).Item("Issue" & z)
txtContent.Text = ds.Tables(0).Rows(i).Item("Issue" & z)
pn = New AjaxControlToolkit.AccordionPane()
pn.ID = "Pane" & z
pn.HeaderContainer.Controls.Add(lblTitle)
pn.ContentContainer.Controls.Add(txtContent)
arcPane.Panes.Add(pn)
End If
pncount = pncount + 1
z = z + 1
b = b - 1
Loop
Every control has a property called Controls, which is a collection of immediate child controls. Looping through them is possible, where you can examine them one by one until you find the one that you want. Each control instance also has a method called FindControl, which you can use to look up controls by their IDs. You should be able to find them this way. Start from the first common parent control (e.g. arcPane).
foreach (Control pane in arcPane.Panes)
{
foreach (Control c in pane.ContentContainer.Controls)
{
//examine c.ClientID or c.GetType() or some other
//property that you can recognize the control by
}
}

Using Per Item Fills in Flex/Actionscript

I am creating a chart using mxml. The mxml tags only create a chart with a horizontal axis and vertical axis.
My result event handler has actionscript code that loops through the xml result set and creates all the series (line series and stacked bar). This part of the code works fine.
Now I need to use the functionfill function to set individual colors to each series. All the examples I have found call the functionfill from within an MXML tag, like so:
<mx:ColumnSeries id="salesGoalSeries"
xField="Name"
yField="SalesGoal"
fillFunction="myFillFunction"
displayName="Sales Goal">
I am having trouble calling functionfill from actionscript.
A portion of the code that build the data series is below:
if (node.attribute("ConfidenceStatus")=="Backlog"
|| node.attribute("ConfidenceStatus")=="Billings") {
// Create the new column series and set its properties.
var localSeries:ColumnSeries = new ColumnSeries();
localSeries.dataProvider = dataArray;
localSeries.yField = node.attribute("ConfidenceStatus");
localSeries.xField = "TimebyDay";
localSeries.displayName = node.attribute("ConfidenceStatus");
localSeries.setStyle("showDataEffect", ChangeEffect);
localSeries.fillFunction(setSeriesColor(xxx));
// Back up the current series on the chart.
var currentSeries:Array = chart.series;
// Add the new series to the current Array of series.
currentSeries.push(localSeries);
//Add Array of series to columnset
colSet.series.push(localSeries);
//assign columnset to chart
chart.series = [colSet];
My setSeriesColor function is:
private function setSeriesColor(element:ChartItem, index:Number):IFill {
var c:SolidColor = new SolidColor(0x00CC00);
var item:ColumnSeriesItem = ColumnSeriesItem(element);
//will put in logic here
return c;
}
What parameters do I put in the line localSeries.fillFunction(setSeriesColor(xxx)) ?
I tried localSeries as the first argument but I get an implicit coercion error telling me localSeries can't be cast as ChartItem.
How do I call the function correctly?
localSeries.fillFunction = setSeriesColor;
The code you have right now is actually CALLING setSeriesColor the way you have it set up. You only want it to refer to a reference of the function, not calling it, so just send it "setSeriesColor" as a variable.

Resources