Telerik.Web.UI.RadComboBoxContext is not supported because it implements IDictionary - c#

private const int ItemsPerRequest = 10;
[WebMethod]
public RadComboBoxItemData[] GetAccount(object context)
{
RadComboBoxContext obj = (RadComboBoxContext)context;
DataTable data = GetDataAccount(obj.Text);
RadComboBoxData comboData = new RadComboBoxData();
int itemOffset = obj.NumberOfItems;
int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count);
comboData.EndOfItems = endOffset == data.Rows.Count;
List result = new List(endOffset - itemOffset);
for (int i = itemOffset; i < endOffset; i++)
{
RadComboBoxItemData itemData = new RadComboBoxItemData();
itemData.Value = data.Rows[i]["AccountLevelNo"].ToString();
itemData.Text = data.Rows[i]["AccountDesc3"].ToString();
itemData.Attributes.Add("Level6", data.Rows[i]["AccountDesc2"].ToString());
itemData.Attributes.Add("Level1", data.Rows[i]["AccountDesc1"].ToString());
result.Add(itemData);
}
comboData.Items = result.ToArray();
// comboData.Message = GetStatusMessage(endOffset, data.Rows.Count);
return comboData.Items.ToArray();
}
private static DataTable GetDataAccount(string text)
{
int accCode = 0;
string query = "select COA.LevelAccountNo,COA.AccountDesc as AccountDesc3,Level1.AccountDesc as AccountDesc1, Level2.AccountDesc as AccountDesc2 from COA COA,(select LevelAccountNo,AccountDesc " +
"from COA where len(LevelAccountNo)=2)as Level1,(select LevelAccountNo,AccountDesc from COA where len(LevelAccountNo)=5)as Level2 " +
"where Level1.LevelAccountNo=left(COA.LevelAccountNo,2)and Level2.LevelAccountNo=left(COA.LevelAccountNo,5) and len(COA.LevelAccountNo)>6";
try
{
accCode = Convert.ToInt32(text);
query = query + " COA.LevelAccountNo like '" + text + "%'";
}
catch (Exception ex)
{
query = query + " COA.AccountDesc3 like '%" + text + "%'";
}
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"].ToString());
// string constr=ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlDataAdapter adapter = new SqlDataAdapter(query, con);
// adapter.SelectCommand.Parameters.AddWithValue("#text", text);
DataTable data = new DataTable();
adapter.Fill(data);
con.Close();
return data;
}
this is my web service code
Collapse | Copy Code
<telerik:RadComboBox ID="cboAccount" runat="server" Height="200" Width="200" EmptyMessage="Select an Account"
EnableLoadOnDemand="true" ShowMoreResultsBox="true" EnableVirtualScrolling="true">
<HeaderTemplate>
<h3>Accounts</h3>
</HeaderTemplate>
<ClientItemTemplate>
<div>
<ul>
<li><span><b>Name:#= Text # </b></span></li>
<li><span>Level6 #= Attributes.Level6 # </span></li>
<li><span>Level1: #= Attributes.Level4 # </span></li>
<li><span>Level4 #= Attributes.Level1 # </span></li>
</ul>
</div>
<br></br>
</ClientItemTemplate>
<WebServiceSettings Method="GetAccount" Path="InvestmentDropDownWebService.asmx" />
</telerik:RadComboBox>
I am using for the first time webservice in my project. I don't know how to solve this error. If I am running aspx.cs this is perfectly running and values bind in combo box. But when I am binding values to combobox by using web service, its gives an error:
The type Telerik.Web.UI.RadComboBoxContext is not supported because it implements IDictionary.

This issue arise because of Visual Studio debugger. It's because of it's default behaviour. There's a workaround for that. Change your line
[WebMethod]
to
[WebMethod(EnableSession = true)]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
And also, Add an attribute of
WebServiceSettings-UseHttpGet="true"
in your ASPX code of RadCombo Box.
See this question in Telerik forum for more details regarding this issue

The cause of the problem is (xml)serialization.
Remember, the serialization-mechanism was built at the very start of the platform, nice things as generic-collections/dictionaries were added after.
This means that functionality that you would expect to work now, may not have been possible during the initial development.
Which brings us to the dictionary.
The base class of the dictionary does not support serialization, because the serializer does not like/handle 'unknown' types very much. Since dictionaries could be '[object, object]', it is unknown-type heaven.
An interesting way to create a similar unknown type problem is as follows.
Create a webservice that expects class 'a' as a parameter.
Create a web-reference to the service.
Create class 'b' that derives from 'a'.
Now call the webmethod with an instance of 'b' as a parameter
You will now get an error message saying that the call failed because 'type b was unexpected'. I hope you can see how these two things (unexpected type/dictionary) are related...
You can only give an xml serializer the types it was told to expect at design-time
The solution of 'sohaiby' will work because he is telling the webservice NOT to use xml-serialization, but to use JSON in the line:
ResponseFormat = ResponseFormat.Json
This all being said, this is really Telerics fault and they should fix it.

Related

Filling a textbox from DropDownList Selection filled itself with CascadingDropDown

I'm quite new to Visual Studio. I'm working right now on Visual Studio Express 2013 and I'm trying to fill a certain textbox in ASP.net
I'll summarize everything as best as I can (I'm not a native english speaker)
First I had this problem with the invalid postback thing. I've found only one correct solution right here : https://johanleino.wordpress.com/2009/11/17/cascadingdropdown-causes-invalid-postback-or-callback-argument-error/
So, that's why I have NoValidationDropDownList instead of classical dropDownList
Also, I have 2 DropDownList using the ajax CascadingDropDown (I'm filling the second one depending on the selected value of the first one)
Here's my view :
<asp:TableCell>
<asp:NoValidationDropDownList OnSelectedIndexChanged="DropDownListVille_SelectedIndexChanged" ID="DropDownListVille" runat="server" class="ddlVille" ></asp:NoValidationDropDownList>
<ajax:CascadingDropDown ID="CascadingDropDown1" runat="server" Category="Ville"
TargetControlID="DropDownListVille" PromptText="Non définie" LoadingText="Chargement des villes"
ServiceMethod="AfficherVille" ServicePath="CascadingDropDown.asmx"></ajax:CascadingDropDown>
</asp:TableCell>
<asp:TableCell runat="server">
<asp:NoValidationDropDownList ID="DropDownListRue" runat="server" class="ddlRue" OnSelectedIndexChanged="DropDownListVille_SelectedIndexChanged"></asp:NoValidationDropDownList>
<ajax:CascadingDropDown ID="ccdRegion" runat="server" Category="Rue" ParentControlID="DropDownListVille"
TargetControlID="DropDownListRue" PromptText="Non définie" LoadingText="Chargement des rues"
ServiceMethod="VilleRueLier" ServicePath="CascadingDropDown.asmx"></ajax:CascadingDropDown>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="TextBoxCP" runat="server" class="tbcp"></asp:TextBox>
</asp:TableCell>
My first dropdown have cities, second one have streets and my textbox have postcode. All data is coming from one DB using these two tables :
Ville(Id_Ville, nom_ville, code_postal)
Translated in
city(id_city,city_name,postcode)
Rue(Id_Rue,Nom_Rue)
Translated in
street(id_street,street_name)
I would like to dynamically change the postcode depending on the id of the selected city (This id is stored as a value in the dropdownlist).
See, when the city the user want is not in the db, he can select a special value of the first dropdownbox, and add a new city.
When he does that, the page display some textbox with ajax.
There, the user can add a new city with its postcode. Else, the postcode TextBox is on readonly.
But when he choose a listed city, I want the textbox to fill itself.
There's my webservice methods, linked to the cascadingDropDown :
[System.Web.Script.Services.ScriptService()]
public class WebService1 : System.Web.Services.WebService
{
private Passerelle.Passerelle passerelle = new Passerelle.Passerelle();
[WebMethod]
public CascadingDropDownNameValue[] AfficherVille(string knownCategoryValues, string category)
{
List<CascadingDropDownNameValue> VilleDetails = new List<CascadingDropDownNameValue>();
ListVille listeVille = new ListVille();
listeVille = passerelle.getListVille();
foreach (Ville v in listeVille.List)
{
string idVille = v.IdVille.ToString();
string nomVille = v.NomVille.ToString();
VilleDetails.Add(new CascadingDropDownNameValue(nomVille, idVille));
Debug.WriteLine("Id Ville = " + idVille + " ----- NomVille = " + nomVille);
}
return VilleDetails.ToArray();
}
[WebMethod]
public CascadingDropDownNameValue[] VilleRueLier(string knownCategoryValues, string category)
{
///GET DATA FROM SQL
ListRue listeRue = new ListRue();
StringDictionary VilleDetails = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
int idVille = Convert.ToInt32(VilleDetails["Ville"]);
List<CascadingDropDownNameValue> countrydetails = new List<CascadingDropDownNameValue>();
//Here I get the data from my table 'Rue' with the ID coming from
listeRue = passerelle.getListRue(idVille);
countrydetails.Add(new CascadingDropDownNameValue("Pas dans la liste", "-1"));
foreach (Rue r in listeRue.list)
{
string idRue = r.idRue.ToString();
string nomRue = r.nomRue.ToString();
countrydetails.Add(new CascadingDropDownNameValue(nomRue, idRue));
Debug.WriteLine("Id rue = " + idRue + " ----- NomRue = " + nomRue);
}
return countrydetails.ToArray();
}
}
I've Tried many things... Classic events to some ajax function calls.
And I just can't figure out how to do that ...
And of course I'm following classic MVC pattern. So... No sql request in the view.
I'm not doing great with ajax.
I'm probably missing some great ajax/asp.net feature with another webMethod.
Many thanks to anyone who can help me.
And sorry for all the spelling/grammar mistakes.
I won't be able to answer for some hours (I'll come back in something like ~12 hours) If you have any questions ... I'll be there to answer you.
Ok my bad.
My event were not working because I forgot the AutoPostBack=true.
Using UpdatePanel all around my view's items to deny refreshing the page, I've now fixed everything.

Xamarin ListView display item from SQLite Database C# Android

in my case i wanted to display items from local SQLite database which i created as shown below:
public string CreateDB() //create database
{
var output = "";
string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "IsoModule.db3");
output = "Database Created";
return output;
}
public string CreateTable() //create table
{
try
{
string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "IsoModule.db3");
var db = new SQLiteConnection(dbPath);
db.CreateTable<UserInfo>();
db.CreateTable<TableInfo>();
string result = "Table(s) created";
return result;
}
catch (Exception ex)
{
return ("Error" + ex.Message);
}
}
and this is my code where i wish to retrieve data
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "IsoModule.db3");
var tablelistout = new SQLiteConnection(path);
var alltables = tablelistout.Table<TableInfo>();
foreach (var listing in alltables)
{
var from = new string[]
{
listing.tname + " - " + listing.status
};
ListView listtable = (ListView)FindViewById(Resource.Id.listtable);
listtable.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, from);
}
the code runs with NO ERROR but it only display last item in the table. it is confusing me, so i would like to ask how can i retrieve all the data from specific table?
or if someone has asked the same question please share me the link. many appreciate.
var alltables = tablelistout.Table<TableInfo>();
var data = new List<string>();
foreach (var listing in alltables)
{
data.Add(listing.tname + " - " + listing.status);
}
ListView listtable = (ListView)FindViewById(Resource.Id.listtable);
listtable.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, data.ToArray());
All I did was move 2 things out of the loop. First, I moved out the initialization of the array. Second, I moved out the listView + assignation of the adapter.
Your issue is that in the loop, you were always overriding everything you had done in the previous iteration (leaving you with the last item like you said).
Also, You should take note that it will be important for you to create a custom adapter if you plan on having a decent amount of data. ArrayAdapter is a native Android class which is then wrapped by a C# Xamarin object, meaning you will have both a C# and Java object per row. It adds overhead as both garbage collectors will have work to do and can cause performance issues. Xamarin devs tend to generally avoid it with the exception of quick prototyping.
On another note, I would use the FindViewById<T>(Int32) instead of the FindViewById(Int32) and casting it. FindViewById<ListView>(Resource.Id.listtable) in your case. Just taking advantage of the power of generics.

Alphanumeric 8 digits unique id for users in C#.net

What I want to do is that I have created a asp.net web application and right now I m using XML to save my data (I AM NOT USING SQL)and my next task is to Generate A unique 8digits Alphanumeric Id for the users which will be used by them In future to track there request.
I have been given a particular format of this ID so I can't use 'GUID'.
The format given is this:
PR000000(PR stands for Project)
NP000000(NP stands for Non-Project)
So, the first two letters will be selected according to the user entry(if its a Project procurement request then 'PR' and in case of Non-project Procurement request 'NP') and rest 6 digits are simple integers which will keep increasing (000001,000002,000003....999999).
I have searched a lot everywhere but its all about php,uniquecode,GUID etc. but I just want a simple code which perform the above task with ease like IF-Else statement + keep increasing the count(000001...000002..).
This is the code for Project and Non project selection:
PROJECT<input type="radio" name="portal" id="radio1" onclick="changeMe(this);"/> <input type="text" name="textprojectOff" id="text1" value="Project Name" onclick="changeMe(this);"/>
NON-PROJECT<input type="radio" id="radio2" name="portal" onclick="changeMe(this)"/> <input type="text" name="textnonprojectOff" id="text2" value="Department" onclick="changeMe(this);"/>
<script type="text/javascript" >
function changeMe(inField)
{
var fieldId = inField.id;
var type = fieldId.substring(0, 4);
if (type == 'text') {
var name = fieldId.substring(4);
var radioButton = document.getElementById("radio" + name);
radioButton.checked = true;
} else {
var name = fieldId.substring(5);
var textField = document.getElementById("text" + name);
textField.focus();
textField.value ='';
}
}
If anyone require my xml code for my help then kindly tell me in the comment section I will post it at that time.
For your requirement, you will have to generate the unique ids from server-side code after checking the existing values in a Database.
you can use a Oracle Sequence if you want. Client side generation should not be used in this case because there is a change that multiple users can get the same unique id. So this generation should be handled server side / db side.
Here I got the solution of My Own problem ,So,I thought to share it with everyone so that other can get help from it. Without Using any typical Function I have generated an Unique Id for each and ever user.
.cs programming:
protected void GetId()
{
MSXML2.DOMDocument objXML = new MSXML2.DOMDocument();
string oPath = null;
oPath = Server.MapPath("PARNId.xml");
XmlDocument doc = new XmlDocument();
if (objXML.load(oPath) == true)
{
objNextId = objXML.selectSingleNode("//Id").text;
}
}
protected void SetId()
{
MSXML2.DOMDocument objXML = new MSXML2.DOMDocument();
string oPath = null;
oPath = Server.MapPath("PARNId.xml");
XmlDocument doc = new XmlDocument();
if (objXML.load(oPath) == true)
{
objXML.selectSingleNode("//Id").text = objNextId;
}
if (RadioButton2.Checked == true)
{
Label1.Text = "Your PURCHASE ACTION REQUEST NUMBER Is : PR" + objNextId;
}
else
{
Label1.Text = "Your PURCHASE ACTION REQUEST NUMBER Is :NP" + objNextId;
}
objXML.save(oPath);
}
Calling both the functions
GetId();
Label1.Text = objNextId;
objNextId = Convert.ToString(Convert.ToInt32(objNextId) + 1);
SetId()
I have created a separate XML file named Track.xml, in which I have assigned a node 100000,and this keep incrementing with every request made and finally I saved the label1.text and this keep record of all PARN generated with each user Hope it helps other!!

Creating an Ektron Smart Form Definition via the API

I've been trying to create a smart form definition from another application. The app successfully creates the smart form, but I'm unable to get the FieldList, DisplayXSLT or Schema fields to populate.
This leaves me with a blank smart form definition (less that ideal).
Here's the code I have to perform the action. Any ideas?
// form is a simple POCO with values copied from an existing SmartForm Definition
var config = new SmartFormConfigurationData();
config.SmartformTitle = form.Name;
config.SmartformDescription = form.Description;
config.XmlSchema = form.Schema;
config.PackageDisplayXslt = form.Xslt;
config.FieldList = form.FieldList;
config.Type = EkEnumeration.XmlConfigType.Content;
var api = new SmartFormConfigurationManager(ApiAccessMode.Admin);
api.RequestInformation.ServicesPath = this.EktronServiceHost;
api.RequestInformation.AuthenticationToken = this.GetAdminAuthToken();
api.Add(config);
Update:
I heard back from Ektron Support on this issue. It's not so much a "bug" per-se... It's more a case of this API class looking very similar to the ContentManager but not behaving like it. I expected that since it looked so similar to ContentManager and many of the other classes, I would be able to call Add() and it would just magically work. It turns out the solution is a little more complicated.
Adding a smartform is a two-step process: first Add(), then Update().
The Add method doesn't set all of the fields and in fact passes in NULL for a few of the parameters on the stored procedure that creates the entry in xml_collection_tbl.
The real fun comes in step 2. Basically, you start with the SmartForm's HTML -- the stuff you see when you're in the "Data Design" view for editing the smart form definition and you click that <> button ("HTML") at the bottom of the editor. You run that through a whole bunch of XSLTs that are burried in the WorkArea folder to construct the missing fields, and then you call update. Here's the code that worked for me:
var sfManager = new SmartFormConfigurationManager();
var data = sfManager.GetItem(12);
if (data == null) return;
var sfcData = new SmartFormConfigurationData();
sfcData.Type = EkEnumeration.XmlConfigType.Content;
sfcData.SmartformTitle = "SmartForm12 copy";
sfcData.SmartformDescription = "SmartForm12 copy";
sfcData.XmlSchema = "";
sfcData.PackageDisplayXslt = data.PackageDisplayXslt;
sfcData.FieldList = data.FieldList;
sfcData = sfManager.Add(sfcData);
Response.Write("SmartForm added with id: " + sfcData.Id);
var design = System.IO.File.ReadAllText(Server.MapPath("~/NewsArticleSmartForm.html"));
var contentApi = new ContentAPI();
var schema = contentApi.TransformXsltPackage(design, Server.MapPath("~/WorkArea/ContentDesigner/DesignToSchema.xslt"), true);
var fieldList = contentApi.TransformXsltPackage(design, Server.MapPath("~/WorkArea/ContentDesigner/DesignToFieldList.xslt"), true);
var viewEntryXslt = contentApi.TransformXsltPackage(design, Server.MapPath("~/WorkArea/ContentDesigner/DesignToEntryXSLT.xslt"), true);
var xsltArgs = new XsltArgumentList();
xsltArgs.AddParam("srcPath", "", "/WorkArea/ContentDesigner/");
var viewXsltSource = string.Concat("<root>", design, "<ektdesignpackage_list>", fieldList, "</ektdesignpackage_list></root>");
var viewXslt = contentApi.XSLTransform(viewXsltSource, Server.MapPath("~/WorkArea/ContentDesigner/DesignToViewXSLT.xslt"), true, false, xsltArgs, false);
var initialDocument = contentApi.TransformXsltPackage(design, Server.MapPath("~/WorkArea/ContentDesigner/PresentationToData.xslt"), true);
var sbPackage = new StringBuilder("<ektdesignpackage_forms><ektdesignpackage_form><ektdesignpackage_designs><ektdesignpackage_design>");
sbPackage.Append(design);
sbPackage.Append("</ektdesignpackage_design></ektdesignpackage_designs><ektdesignpackage_schemas><ektdesignpackage_schema>");
sbPackage.Append(schema);
sbPackage.Append("</ektdesignpackage_schema></ektdesignpackage_schemas><ektdesignpackage_lists><ektdesignpackage_list>");
sbPackage.Append(fieldList);
sbPackage.Append("</ektdesignpackage_list></ektdesignpackage_lists><ektdesignpackage_views><ektdesignpackage_view>");
sbPackage.Append(viewEntryXslt);
sbPackage.Append("</ektdesignpackage_view><ektdesignpackage_view>");
sbPackage.Append(viewXslt);
sbPackage.Append("</ektdesignpackage_view></ektdesignpackage_views><ektdesignpackage_initialDocuments><ektdesignpackage_initialDocument>");
sbPackage.Append(initialDocument);
sbPackage.Append("</ektdesignpackage_initialDocument></ektdesignpackage_initialDocuments></ektdesignpackage_form></ektdesignpackage_forms>");
sfcData.PackageXslt = sbPackage.ToString();
sfcData.FieldList = fieldList;
var baseFilename = "SmartForm" + sfcData.Id;
var schemaFilename = "/" + baseFilename + "Schema.xsd";
var xsltFilename = "/" + baseFilename + "Xslt.xslt";
sfcData.XmlSchema = schemaFilename; // The file will be prefixed with /XmlFiles
var unPackDisplayXslt = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:output method=\"xml\" version=\"1.0\" encoding=\"UTF-8\" indent=\"yes\"/><xsl:template match=\"/\"><xsl:choose><xsl:when test=\"ektdesignpackage_forms/ektdesignpackage_form[1]/ektdesignpackage_views/ektdesignpackage_view[2]\"><xsl:copy-of select=\"ektdesignpackage_forms/ektdesignpackage_form[1]/ektdesignpackage_views/ektdesignpackage_view[2]/node()\"/></xsl:when><xsl:otherwise><xsl:copy-of select=\"ektdesignpackage_forms/ektdesignpackage_form[1]/ektdesignpackage_views/ektdesignpackage_view[1]/node()\"/></xsl:otherwise></xsl:choose></xsl:template></xsl:stylesheet>";
var displayXslt = contentApi.TransformXsltPackage(sbPackage.ToString(), unPackDisplayXslt, false);
System.IO.File.WriteAllText(Server.MapPath("~/XmlFiles" + xsltFilename), displayXslt);
sfcData.Xslt1 = xsltFilename; // The file will be prefixed with /XmlFiles
sfcData.DefaultXslt = 1;
sfManager.Update(sfcData);
I extracted the HTML for my existing smart form and saved in the root of my site as NewsArticleSmartForm.html. Here's what my file looked like:
<p>Author: <input type="text" name="Author" id="Author" ektdesignns_caption="Author" ektdesignns_name="Author" title="Author" ektdesignns_indexed="false" ektdesignns_nodetype="element" size="24" class="design_textfield" /></p>
<p> </p>
<p>Article Summary: <textarea name="Summary" id="Summary" ektdesignns_caption="Summary" ektdesignns_name="Summary" title="Summary" ektdesignns_indexed="false" ektdesignns_nodetype="element" cols="40" rows="3" class="design_textfield"></textarea>
</p>
<p> </p>
<p>Article Body:</p>
<p> </p>
<ektdesignns_richarea id="Body" name="Body" ektdesignns_caption="Body" ektdesignns_name="Body" title="Body" ektdesignns_indexed="false" ektdesignns_nodetype="element"> </ektdesignns_richarea>
<p> </p>
Good luck!
Original Answer:
Creating a copy of a SmartForm configuration should be fairly straight-forward. The SmartFormConfigurationData object has a Clone() method on it which makes it really easy to create a copy of an existing SmartForm. I say "should be" because it doesn't work.
I had an answer all typed out ready to post; I tried some code and it appeared to work. The new smartform was listed in the workarea, but when I clicked on that new smartform to view its details, I realized something was wrong.
I tried the following code:
var sfManager = new SmartFormConfigurationManager();
var config = sfManager.GetItem(7);
if (config == null) return;
var newSmartForm = config.Clone();
newSmartForm.SmartformTitle += " copy";
sfManager.Add(newSmartForm);
Here are the details from the original smartform:
And here's what the new smartform looked like -- the one I created with the frameworkAPI:
I did find one API method that successfully created a copy of an existing smartform:
var sfApi = new Ektron.Cms.ContentAPI();
var newId = sfApi.ReplicateXmlConfiguration(7, "copied sf title");
The problem with that method is that the smartform must exist on your system and you can only change the title. So, I went digging into the database to see what was happening. It turns out that after calling this ReplicateXmlConfiguration() method, the two database records are identical (except for the expected LastUpdated type of fields).
After calling the frameworkAPI's Update() method (same holds true when calling Add()), the "updated" record is clearly different.
I think we've got a genuine bug here. This happens both in v8.7 sp2 and v9.0 sp1. I've opened a case with Ektron support, and I'll update my answer as I hear back. They have always been very responsive when I've dealt with them in the past.

Throwing a popup when search yields no results

Here's the deal. Have a functioning web app using ASP.NET WebForms with a C# backend. The thing works fine, but I'm always looking to improve, as a beginner at this stuff. Right now, to deal with a user's search coming back with no results, I utilize the following, and was wondering if there was any cleaner way to do it, for future reference:
DataClass data = new DataClass();
var searchresults = data.GetData(searchBox.Text);
int datanumber = searchresults.Count();
if (datanumber == 0)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "javascript:alert('There were no records found to match your search');", true);
}
else
{
DropDownList1.Visible = true;
DropDownList1.Items.Clear();
DropDownList1.DataSource = searchresults;
DropDownList1.DataBind();
}
I agree with the not using popups, so you could always do something as simple as having a Label object on your page:
<asp:Label runat="server" id="lblResultMsg" ForeColor="Red" Visible="False" />
And then set the text dynamically (or add it as a property to the code) and set the label to be visible on postback if no results are found:
if (datanumber == 0)
{
lblResultMsg.Text = "There were no records found to match your search.";
lblResultMsg.Visible = true;
}
else
{
lblResultMsg.Text = "";
lblResultMsg.Visible = false;
// do your data binding
}
But there are quite a vast number of ways you could achieve something like this. Regarding your question about using the .Count from the Enumerable collection - there's nothing stopping you doing this as it's perfectly valid. The question is which method do you find more readable?
if you include the jquery ui dialog (http://jqueryui.com/demos/dialog/), you can simply call this to create a nice dialog box:
$('<div>message</div>').dialog({autoOpen:true,title:'Error'});
Personally I prefer to create a helper function for inserting the relevant javascript into the page, and only pass parameters to the function so that I don't need to worry about the messy details every time.
Something like :
public static void GrowlMessage(System.Web.UI.Control pageControl, string header = "", string message = "", bool sticky = false, string position = "top-right", string theme = "", bool closer = true, int life = 8)
{
string _js = "$.jGrowl('" + HttpContext.Current.Server.HtmlEncode(message) + "', { header:'" + header + "', sticky:" + sticky.ToString().ToLower() + ", position: '" + position + "', theme: '" + theme + "', closer: " + closer.ToString().ToLower() + ", life:" + life * 1000 + "});";
ScriptManager.RegisterStartupScript(pageControl, pageControl.GetType(),"Growl",_js, true);
}
The sample I have used also requires jQuery and the jGrowl library available here. And IMHO the messages are pretty. They are unobtrusive, the user does not need to click a button to make them go away, and they fade away after your specified amount of time.
But I agree with Mike, that if you don't have any records, you should just use the built in properties of a GridView (EmptyDataRowStyle and EmptyDataRowText) to display a 'no data matching your query' style message. Assuming that you're using a GridView at all, that is..
When it comes to user feedback, Impromptu is my friend. There is a nice ASP.NET implementation of Impromptu on Aaron Goldenthal's website: http://www.aarongoldenthal.com/post/2009/11/11/Using-jQuery-Impromptu-With-ASPNET.aspx
If you have decided to alert user via alert then please go ahead with light box effect..
http://www.designyourway.net/blog/resources/30-efficient-jquery-lightbox-plugins/
if you are still would like to go ahead with traditional alert then obviously its easy for you to fire it up on page load rather than attaching script to it..
')" ....>
Because if you require any change then you just need to alter the javascript alone and you dont need to build project again to test it...
Hope its useful for you..
Note: I'm using my own DLLs to render content so above coding may requires alteration because i did forget traditional asp codings.. :)

Categories

Resources