I am working on a Visual web part in which I need to list matching data when user type something in text box (like in Google search or Question Title in StackOverflow).
I have ended up in lots of results, but it is for typical c# application. I am looking for a solution which can be implemented directly in my visual web part. I am using SharePoint 2010 and VS 2010.
I did the following things
Installed Ajax Control tool kit.
Added the Items to VS toolbox
and added the following code snippet.
in .ascx file
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
<asp:TextBox ID="txtMovie" runat="server"></asp:TextBox>
<asp:AutoCompleteExtender
ID="AutoCompleteExtender1"
TargetControlID="txtMovie" ServiceMethod="GetCompletionList"
runat="server" UseContextKey="True" />
in .ascx.cs
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static string GetCompletionList(string prefixText, int count, string contextKey)
{
return "Hello";
}
But when I deployed I am getting this error
Only one instance of a ScriptManager can be added to the page.
I removed the <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager> from my .ascx file however after that I am not able to edit my sharepint pages because of some js error.
Not sure why it is not working, came across a codeplex feature that will do the trick for you: http://spautocomplete.codeplex.com/
Also, check out this jQuery solution: http://sharepointwings.blogspot.in/2012/05/autocomplete-textbox-using-jquery-in.html
There is also one available from: Microsoft.Office.Search.WebControls.AutoCompleteExtender
regards,
KS
Related
I m very new to visual studio and dnn and I m learning the "basics" with a book. I m trying to build my very first module at the moment . In one of the ascx files I have the following code:
<%# Control Language="C#" AutoEventWireup ="true" CodeBehind="Settings.ascx.cs" Inherits="wrox.Modules.guestbook.Settings" %>
<%# Register TagName="label" TagPrefix="dnn" Src="~/controls/labelcontrol.ascx" %>
<fieldset>
<div class="dnnFormItem">
<dnn:Label ID="lblAutoApprove" runat="server" ResourceKey="lblAutoApprove"
ControlName="chkAutoApprove" />
</div>
</fieldset>
<asp:CheckBox runat="server" ID="chkAutoApprove" />
The following piece of code gives the following warning: file '~/controls/labelcontrol.ascx" was not found
<%# Register TagName="label" TagPrefix="dnn" Src="~/controls/labelcontrol.ascx" %>
I need to use the labecontrol.ascx file for this piece of code.
<div class="dnnFormItem">
<dnn:Label ID="lblAutoApprove" runat="server"
ResourceKey="lblAutoApprove"
ControlName="chkAutoApprove" />
</div>
This piece of codes give the following warning because the labecontrol.ascx file is missing (As far as I know):Element 'Label' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.
I found two simular questions on this site.
The first one wasn't very helpfull because the answer was to ignore the warning. I dont want to do this.
The second question wasn't helpfull either because he/she had a typo.
How can I get rid of this warning?
notes:
I m using visual studio 2017 and dotnetnuke 8
Its been a while since I have done DNN development but the issue is generally that when you are making a custom module, you make it with the context that the rest of DNN is there, but during develop-time, the rest of DNN is not actually there (or at least not where Visual Studio expects to find it).
I would imagine you could get rid of the warning by copying the DNN label control into the controls folder of your module. If you do this, I would make sure your build does NOT include the DNN control and that you put it in whatever ignore list your source control uses.
I am going thru this article here which talks about using the Razor template for Xamarin forms. I am however unable to find such a template in Visual Studio. The closest I came to was a nuget package. I don't think I can use that if I am to follow the example in the article above. Has anyone found any such problem before or can this only be done on Xamarin studio?
Why would they not make a provision for Visual Studio as well!
Just tried to use a razor template inside a Xamarin.Forms PCL and stumbled over the missing template. But then I followed the advice in the comments and it worked without any problems.
Add a new class (or whatever you want) to the portable project and name the file RazorTest.cshtml.
Replace the content of the new file with a skeleton like this:
Adjust the namespace and bind to your own ViewModel:
#using RazorTestNamespace.ViewModels
#model RazorTestViewModel
<html>
<body>
<h1>#Model.Title</h1>
</body>
</html>
Go to the class properties, find the CustomTool property and type in RazorTemplatePreprocessor. Then VisualStudio magically creates the belonging RazorTest.cs file with the code-behind.
Build the HTML when needed:
Inside the ViewModel:
RazorTest razorTest = new RazorTest { Model = razorTestViewModel };
string html = razorTest.GenerateString();
I have a question about Kendo UI. I have an existing MVC4 project in which I wanted to use some of the Kendo extensions, namely the Editor. Currently the project uses jqWidgets as a UI framework.
I opened VS 2012, loaded the project and used the Telerik menu to add references to Kendo in the project. The wizard added all the necessary references and made changes to the web.config files. So far so good. However, I have two problems:
When I try to use the Kendo Html Helper I do not have intellisense and the Kendo is underlined saying that the HtmlHelper does not have a definition for 'Kendo'. I have <add namespace="Kendo.Mvc.UI" /> in both, my main web.config as well as in the web.config in the Views folder. Strangely enough, when I run the site, I do not get an error, but the editor does not load its initial content and if I try to interract with it, I get the following error: (my second question)
TypeError: invalid 'in' operand e - I am guessing that somewhere in the site, There is a conflict that couses this error, but I cannot find it. Here is how I load all the JS files in my _Layout.cshtml:
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/jqueryui")
#Scripts.Render("~/Scripts/kendo/2013.2.918/kendo.all.min.js")
#Scripts.Render("~/Scripts/kendo/2013.2.918/kendo.aspnetmvc.min.js")
#Scripts.Render("~/Scripts/kendo.modernizr.custom.js")
I am not sure if the problems are related. My jQuery version is 1.9.1 and I am using the latest Kendo version (2013.2.918.340)
Any help would be greatly appreciated.
Here is how I use the editor in the View:
#(Html.Kendo().Editor()
.Name("editor")
.HtmlAttributes(new { style = "width: 700px; height: 400px" })
.Value(#<text>
<p>
Some text
</p>
</text>)
.ImageBrowser(imageBrowser => imageBrowser
.Image("~/Content/UserFiles/Images/{0}")
.Read("Read", "ImageBrowser")
.Create("Create", "ImageBrowser")
.Destroy("Destroy", "ImageBrowser")
.Upload("Upload", "ImageBrowser")
.Thumbnail("Thumbnail", "ImageBrowser"))
)
The solution to the first problem is to add namespace reference only to the web.config file in the Views folder. There is no need to add it to the root web.config. After that restart Visual Studio and reload your project. Everything should be fine and intellisense should work.
As for the second problem, this is hard to guess. Could you show your code where you are loading the contents into HTML editor?
I have a very weird situation. I'm using a ReportViewer control in ASP.NET to show a report in my aspx page. This works fine when i build my web site with VS2008. But it goes wrong when i add a Report Viewer control to a page in VS2010...
The problem i have with the ReportViewer in VS2010 is that it constantly keeps refreshing my report. When i view the network traffic that i send from that page i can clearly see the ReportViewer is constantly sending a new request to get the report. I have no clue why it is behaving like this, and only in VS2010...
But this ONLY happends when i try to add a parameter to my report.
This is what my code looks like:
VS2008
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
Font-Size="8pt" Height="642px" ProcessingMode="Remote" Width="896px">
<ServerReport ReportPath="http://server.com/Product/Dashboards/test.rdl"
ReportServerUrl="http://server.com/ReportServer" />
</rsweb:ReportViewer>
VS2010
<rsweb:ReportViewer ID="ReportViewer1" runat="server"
ProcessingMode="Remote" Width="948px" Font-Names="Verdana" Font-Size="8pt"
WaitMessageFont-Names="Verdana"
WaitMessageFont-Size="14pt">
<ServerReport ReportPath="http://server.com/Product/Dashboards/test.rdl"
ReportServerUrl="http://server.com/ReportServer" />
</rsweb:ReportViewer>
Code behind
For both VS2008 and VS2010 i have the following code in my Page_Load:
ReportParameter[] reportParameters = new ReportParameter[1];
reportParameters[0] = new ReportParameter("year", "2012", true);
ReportViewer1.ServerReport.SetParameters(reportParameters);
ReportViewer1.ServerReport.Refresh();
Why do i have problems with VS2010 when i add parameters, ie: Why does it keeps refreshing my report? And why is this working perfectly fine in VS2008?
This may be the problem you're encountering: Reports Never Stop Loading With VS 2010
Apparently you need a check for IsPostBack before calling SetParameters.
I know this is in an old one, but for those still looking I had this problem in ReportViewer2012 and solved it by checking for a post back in the code behind.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Your code behind code here
}
}
This may also help: https://social.msdn.microsoft.com/Forums/en-US/deae558c-977f-484e-86ba-50cfd376c181/reportviewer-constantly-refreshing?forum=vsreportcontrols
I am trying to get Jquery intellisense working in Visual Studio 2010.
I've looked around on StackOverflow and tried adding this to my view:
#{
/// <reference path="/Scripts/jquery-1.5.1-vsdoc.js"/>
}
That's not working.. I've got it working by adding the same script tag to each view but this is less than ideal since i want to keep all my scripts in one place at the bottom of my layout page.
Add the <script> tags to each view inside an #if (false) { ... } block.
The IDE will still see them, and provide IntelliSense, but they won't do anything at runtime.