i have tried the following way,
http://devendra-sharepoint.blogspot.in/2012/01/creating-list-programatically-in_30.html
But i am not able to create list.
Becuase i am getting the following error.
'Microsoft.SharePoint.SPWeb' does not contain a definition for 'EnsureList' and no extension method 'EnsureList' accepting a first argument of type 'Microsoft.SharePoint.SPWeb' could be found (are you missing a using directive or an assembly reference?)
Please advice.
Thanks,
Aasai
You can do something like this.
private SPList CreateList(string LName)
{
if (spWeb.Lists.TryGetList(LName) == null)
{
spWeb.AllowUnsafeUpdates = true;
spWeb.Lists.Add(LName,"This is Programatically created list", SPListTemplateType.GenericList);
}
return spWeb.Lists[LName];
}
Thanks
Related
I have built my own module and in the BO when I search my module and trying to translate it I am redirected to
"shopadmin/index.php/improve/international/translations/?lang=fr&type=modules&locale=fr-FR&selected=Module_Name&_token=OeEwKt4lWTUTcBerD-_w7LXvoA1Dyl3lcu3cBrYtkaA"
instead of
"shopadmin/index.php?controller=AdminTranslations&type=modules&module=ag_jsccustom&lang=fr&token=a74aaad65ca627b7ca6bfdc37235594f"
Anyone can help me with this weird issue?
I found the solution. You have to add this function to your module’s main class:
public function isUsingNewTranslationSystem()
{
return false;
}
First of all I am beginner, using asp.net core web API (3.1), so my question is in the below code why not able to call the toListAync method.
While calling toListAsync method getting error. Can anyone suggest some tips to solve the problem. I was trying to call the method as an async with dapper.
Error:- Task<IEnumerable<Owner>> does not contain a definition for toListAsync and no accessible extension method toListAsync accepting a first argument of type Task<IEnumerable<Owner>> could be found (are you missing a using directive or an assembly reference?)
public async Task<IAsyncEnumerable<Owner>> GetCustomerAsync()
{
IAsyncEnumerable<Owner> owners = null;
var query = "select * from tbl_Owner";
using (var sqlCon = new SqlConnection())
{
var k = await sqlCon.QueryAsync<Owner>(query).toListAsync();
return owners;
}
}
Did you forget to import the corresponding package?
Try to add:
using System.Data.Entity;
For EF Core ,you can add the following assembly reference:
using Microsoft.EntityFrameworkCore;
I have a XAML workflow which, which uses custom activities that are stored in more than one dlls. I’m trying to execute this workflow using WorkflowApplication. However I cannot figure out how to resolve multiple reference assemblies, while loading the XAML. I’m aware that the XamlXmlReaderSettings provides a LocalAssembly property, which allows us to provide the reference assembly. However, it only allows to provide a single assembly. How do I provide multiple reference assemblies to the reader, so that it is able to resolve the external types? Any help will be greatly appreciated. I’ve pasted the code I’m using for reference.
public void LoadWorkflowFromFileAsync(string workflowXaml, Assembly activityAssembly)
{
var xamlReaderSettings = new XamlXmlReaderSettings
{
LocalAssembly = activityAssembly
};
var xamlSettings = new ActivityXamlServicesSettings
{
CompileExpressions = true
};
using (var reader = new XamlXmlReader(workflowXaml, xamlReaderSettings))
{
_activity= ActivityXamlServices.Load(reader, xamlSettings);
}
}
Does your xmlns in the XAML include the assembly name (ex. xmlns:ede="clr-namespace:Sample.MyActivityLibrary;assembly=Sample.MyActivityLibrary")?
I'm not aware of anyway to reference multiple local assemblies in XamlXmlReaderSettings but if the assembly is referenced in the XAML it should resolve automatically.
I'm attaching a event receiver to a single list (Web scope). But the ER runs for all lists in the Web. This question says that the feature, the ER is deployed in, have to be Web scope. This is the case.
The Feature is activated programmatically bound to an ER of a list in the TLS.
newProjectWeb.Features.Add(new Guid("57e21870-6285-4e0a-b9a0-067f774492ae"));
Please see my code below. Am I missing an Update or anything?
Thanks for your help in advance.
public void AddEventReceiverToMemberList()
{
try
{
_clsLists.AddEventReceiverToList(Web, ProjectMemberList.LIST_INTERNAL_NAME, typeof(SCMUProjectMemberList), SPEventReceiverType.ItemAdded);
_clsLists.AddEventReceiverToList(Web, ProjectMemberList.LIST_INTERNAL_NAME, typeof(SCMUProjectMemberList), SPEventReceiverType.ItemDeleting);
_clsLists.AddEventReceiverToList(Web, ProjectMemberList.LIST_INTERNAL_NAME, typeof(SCMUProjectMemberList), SPEventReceiverType.ItemUpdated);
Web.Update();
}
catch (Exception)
{
throw;
}
}
public void AddEventReceiverToList(SPWeb web, string listName, Type eventReceiverClass, SPEventReceiverType eventType)
{
SPList list = this.GetListByName(web, listName);
string className = eventReceiverClass.FullName;
string assemblyName = Assembly.GetAssembly(eventReceiverClass).FullName;
list.EventReceivers.Add(eventType, assemblyName, className);
}
If you want to run the event receiver for a single list..
Refer Here
Check the end of the post, Changing the attribute to "ListTemplateId" to "ListURL" in Elements.xml
In the Elements.xml file replace:
<Receivers ListTemplateId="100">
by
<Receivers ListUrl="Lists/Your List Name">
I have a strange Problem in Zend Framework 2. I've used the Zend Skeleton Application (https://github.com/zendframework/ZendSkeletonApplication) and added PhlyContact as Vendor Module (https://github.com/weierophinney/PhlyContact). I changed the Translation-Type to PhpArray so that i can use the Zend_Validate.php located in the resources-dir of the ZF2-Dist.
Everything translates EXCEPT the validation Messages :/ So i guess i am missing something:
I must pass the Translator to Zend_Validate (but how and where?)
The Translation should use a Text-Domain, but doesn't
When i remember right in ZF1 you had to set the Translator to default to pass it to Zend_Validate. Any Ideas on that !?
have a look at these methods
\Zend\Validator\AbstractValidator::setDefaultTranslator();
\Zend\Validator\AbstractValidator::setDefaultTranslatorTextDomain();
You can even do this with only one line (2nd parameter is text domain):
AbstractValidator::setDefaultTranslator($translator, 'default');
Example within Module.php:
use Zend\Validator\AbstractValidator;
class Module
{
public function onBootstrap(MvcEvent $e)
{
$translator = ....
AbstractValidator::setDefaultTranslator($translator, 'default');
}
}