I am working on a SharePoint 2016 Project which uses SharePoint Application pages. We have a separate user control to which is used to capture address and it is used in other parts of the application.
In order to use this, I have added the user control in to the SharePoint application Page as follows.
<%# Register TagPrefix="uc" TagName="StreetAndPostalAddress" Src="~/_controltemplates/15/Test.Features.WebParts/QAS/QASAddressStreetAndPostal.ascx" %>
And tried to use this control in the page as below.
<uc:StreetAndPostalAddress id="locationAndPostalAddress" runat="Server" />
As soon as I add this control to the page it gives me an error as below. I have tried but was unable to figure out a clue on this. Main reason was same control was working on a another page. Please share your thoughts to resolve this.
Thank you.
I noticed the page used a update panel as follows
<asp:UpdatePanel ID="UP_Accordion" runat="server" UpdateMode="Conditional" ClientIDMode="Static" >
Any Idea on what is the use of it?
First Solution
It was defined <%# Control ClientIDMode="static" > in the page and once I change it to <%# Control ClientIDMode="Predictable" > the issue got resolved. But the functionality of the page is not working. Because JavaScript/Jquery is not working. Which Still did not resolve my issue :(
Finally I figured out why the page is not working. It consists of a accordion and a Grid. And I had a requirement to repeat a same user control. Due to the ClientIDMode which was set to static I had the above error. I read this areticle to understand the concept of ClientIDMode and removed it from the page. Use below link to learn it.
1) https://weblog.west-wind.com/posts/2009/nov/07/clientidmode-in-aspnet-40
Once I removed the ClientIDMode it seems my jquery in the page is not working. I had to change the jquery selector for ID and had select using a pattern match. Once changed the page rendered correctly.
2) How to stop ASP.NET from changing IDs in order to use jQuery
After lots of research still I do not have an answer.
I use WebForm app VS 2013.
My code is fairly simple:
Server.Transfer("~/Success.aspx",true);
After this, load event of Success.aspx is executed but in the browser I only see original Main form.
I created any empty Web Form with only a Button on it but after running the following code
Server.Transfer("~/WebForm2.aspx",true);
still I see MainForm.aspx,(Page_load event handler of WebForm2 runs)
==========================
Update per IrishGrifgin's comments.
I indeed have aJax in my code. I do have UpdatePanels which use Ajax.If this is the problem for server.Transfer how can we resolve this?
Finally I found the solution. Thank you all for your help(+1 for everyone who gave me an idea).
So here was my code:
cs: Server.Transfer("~/Success.aspx",false);
HTML:
<div id="submit">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" UseSubmitBehavior="False" />
</div>
As mentioned Submit button was inside an Update panel.
In this case we need to use the following code :
<Triggers>
<asp:PostBackTrigger ControlID="btnSubmit" />
</Triggers>
This code basically makes the execution of the submit button Synchronous(overrides the Update-panel Behavior).
I don't think you understand what Server.Transfer() does.
It temporarily redirects the code to run the code in the second page.. but it returns control back to the original page once complete. It's entirely possible that the browser won't get (or see) the html from the second page.
See https://msdn.microsoft.com/en-us/library/ms525800(v=vs.90).aspx
If you want to completely turn control over to a second page then you need to use Response.Redirect. If your business rules say you can't use this, then I'd suggest you revisit the business rules and change them.
Without seeing much of the code, it's hard to really debug this issue. Use the Response.Redirect function instead.
Response.Redirect("~/Success.aspx");
I'm pretty new to this, infact this is my first post.
I'm using Visual Studio 2005. On my .aspx page, I have a 'loginStatus' control so the user can logout of a page which works well. However the 'loginStatus' control is not a button, it's text ("logout"). Is it possible to make this into a button?
Here is the line of code:
<asp:LoginStatus ID="LoginStatus1" runat="server" OnLoggingOut="LoginStatus1_LoggingOut" />
Would I just add some style somehow? If so, please help me.
Thanks.
Haven't tested this, but it might solve your problem : forum post
Otherwise you might use jQuery to solve this. (I think...)
You can try this:
<asp:LoginStatus ID="HeadLoginStatus" runat="server"
LogoutAction="Redirect"
LogoutText="<input type='button' value='Log Out' />"
LogoutPageUrl="~/"/>
The LogoutText attribute contains the definition of a simple button, that you can customize with css and js.
Just use LoginImageUrl or LogoutImageUrl
<asp:LoginStatus runat="server"
LogoutImageUrl="~/App_Themes/Theme1/Images/logout.png"
LoginImageUrl="~/App_Themes/Theme1/Images/login.png" />
Using JavaScript:
Grab the url of the link and add a button which, when onclick'ed, points the browser to that url. Then add display:none to the original link with CSS.
You can also use an image as Colin says, but that would fake a button and I assume you want a real button.
YOu could try to render it using an Image, as stated here
The LoginStatus control displays either a text or an image link, depending on the setting of the LoginImageUrl and LogoutImageUrl properties. You can display either text or images for one or both states.
Cheers, I will have a look into this :)
I think it's strange that the option of turning it into a button is not already available.
You could wrap the LoginStatus inside of a LinkButton (Or any kind of button).
<asp:LinkButton id="LinkButton1" runat="server">
<asp:LoginStatus id="LoginStatus1" runat="server" />
</asp:LinkButton>
then use the LinkButton1 events.
You could always just extend the LoginStatus control by creating a derived class, and overriding the rendering behaviour to change the output elements into your desired elements, or add style attributes, or whatever.
(apologies for VB)
Public Class MyLoginStatus
Inherits System.Web.UI.WebControls.LoginStatus
Public Overrides Sub RenderBeginTag(ByVal writer As System.Web.UI.HtmlTextWriter)
writer.AddStyleAttribute("display", "none")
MyBase.RenderBeginTag(writer)
End Sub
End Class
This kind of behaviour could be extended to turn the output into a button, if you so wish, either in aggregate (modifying the final rendered output by creating your own HtmlTextWriter enclosing a StringWriter and invoking the base methods), or by injecting your own behaviour into the relevant render events.
Have you looked into Control Adapters - this allows you to alter the HTML generated. It's primarily used for adapting HTML for different browsers and devices, but can be used to have complete control over server controls.
Lee
I know this is an old post but I'll chime in.
Here's a very simple way to make a button out of the LoginStatus control. Set the control CssClass to a bootstrap button and your good to go. Whatever text you have for the login and logout will go into the button.
<asp:LoginStatus ID="LoginStatus1" runat="server" CssClass="btn btn-primary" LogoutPageUrl="yourlogin.aspx" />
http://www.w3schools.com/bootstrap/bootstrap_buttons.asp
How do I disable an if the user is not logged in?
<asp:MenuItem NavigateUrl="~/Customizations.aspx" Text="Customizations" Enabled="<%# Page.User.Identity.IsAuthenticated %>" />
Doesn't work, even if I specify Page.DataBind() in the Page_Load method.
<% if (HttpContext.User.Identity.IsAuthenticated) { %>
<asp:MenuItem NavigateUrl="~/Customizations.aspx" Text="Customizations" />
<% } %>
Gives the error: Parser Error Message: Code blocks are not supported in this context.
I tried adding an ID attribute, and it gives an error saying it isn't a supported attribute.
Any ideas?
While trying to make webforms like winforms, Microsoft came up short and hasn't faithfully represented a lot of the properties in the winforms MenuItem object, specifically the Visible property. They've also sealed the class barring the ability to work around this oversight through polymorphism.
It would be brilliant to be able to do something like this:
<asp:MenuItem NavigateUrl="~/Customizations.aspx" Text="Customizations" Visible="<%# HttpContext.User.Identity.IsAuthenticated %>/>
You're unfortunately probably going to have to resort to either building or modifying your list in the code-behind.
I would say default the ones that may be in question for users by setting Visible="false" and for the ones that should be visible, set Visible=true in code... there isn't any good inline support for this in web forms.
HTH
Whenever I attempt to set text on the WaterMark Extender (which is on a control) dynamically I get an error saying the that TextBoxWatermarkExtendor missing required watermarktext property value for textboxWatermarkExtender1. The problem is I ONLY get this error some of the time on some computers. It seems to be a loading issue and not browser specific. Does anyone know where I can get some more info about this?
You may not be actually setting the property for watermarktext for the extender.
Take a look # this
<asp:TextBox ID="txtWatermark" runat="server" Width="200px"></asp:TextBox>
<cc1:TextBoxWatermarkExtender ID="txtWatermark_TextBoxWatermarkExtender" runat="server"
Enabled="True" TargetControlID="txtWatermark" WatermarkText="Type Your Search Here">
</cc1:TextBoxWatermarkExtender>
But it is strange that it works only in some computers. Make sure Javascript is turned on in the browsers.
This website has a great tutorial on Watermarked Textboxes + much more :)