I have 2 instances of same webpart deployed on same page.
Webpart has a property named Network, which will take values Internal or External.
Webpart1 is setup as internal. and Network on WebPart2 is setup as external.
After adding webpart, on any event on first webpart is working fine. Any event on Second Webpart shows Network value as Internal. It works fine if I remove the first webpart from the page.
Any ideas?
Share your code related to the Web Part Property in order to give a solution.
One possible scenario might be that the property or encapsulated field might have been declared as static in the web part source.
Related
How can I prevent that the default views are exposed in my Domino application? is there a special $$form for that?
It seems my application now and looses it web launch property
You can hide all views from web. If it's an XPages application, all views are accessed server-side so never need to be accessible from browser.
You can create a form called $$ViewTemplateDefault and leave it empty. All views opened from web (with for example the command ?OpenView) will then just display an empty page.
There are a couple ways to do that. One is with ACL entries. The other (which you refer to) is to create a form called $$View Template for [View name] For example, if your view is called All documents, the form would be called $$View Template for All Documents. Just leave the form blank, or put some static text on it ("Access Denied" perhaps.) You should also have one called $$ViewTemplateDefault which will cover any views you haven't explicitly protected.
I have created a visual web part that has one entry form, it contains 10 textboxes and a submit button to insert the data.
Now on click of submit button it redirects to another page(page is application page deployed under layout folder of same site. this page is added in same web part solution by adding new item).
I'm able to redirect to application page using SPUtility.Redirect(). but not sure about best approach to pass the data from web part page to application.
I think that query string is not a good solution. Also enabling session is manual work on each environment(as i experienced that in one server when i created session variable i got an error to enable it, but in other dev server i was able to do that).
I have done this using a public class in user control .cs page and defined all fields as static variables in side the class. now I'm able to access them in application page added inside layout folder of same project solution. Not sure if it is right approach , but it works
I am having working with sandbox solution. i have one .aspx page in my solution and i have placed one button tag in that page, i need to write server side code for that button. But it is showing "The event handler 'OnClick' is not allowed in this page." . Does codebehind is not allowed in sandbox solution. Or indirectly how can i write my c# code for that button.
I know we can do it by creating one webpart and show that webpart in page using "WebPartPages:SPUserCodeWebPart" tag . But i want to confirm whether we can write codebehind for an asp page in some way or not.
Without changing the web.config file (which would not be recommended in this case), inline code or code behind files are not supported outside of the layouts folder (which you cannot deploy to with a sandbox solution).
However, you should be able to create a class and then set the inherits attribute to point to that class, instead of referring to the class in a code behind file.
What’s the best way to add a custom masterpage to a subsite that is being created programmatically in a feature event receiver? Each of these 50 subsites gets its own “_catalogs/masterpage”, so I have a feeling that Elements.xml for the root-site’s Module/Elements.xml is out. More feature receiver code? PowerShell post-deployment processing?
Is this going to be 50 copies of the same Master Page?
If not, I can't really picture how the Master Page will be specially made using code, but also a Feature Module element is certainly out.
But if it is 50 copies of the same file, you could deploy the Master Page to the Gallery one time using a Feature Module element. Then in your Feature Receiver, make a copy of that file with a new name in the Master Page Gallery and attach it to your website:
web.MasterUrl = "_catalogs/masterpage/custom_v4.master";
web.CustomMasterUrl = "_catalogs/masterpage/custom_v4.master";
web.Update();
You might want to think about creating
custom site definition.
You have following choices to set master page for the site:
1) Using Sharepoint Browser UI (from Site Settings page)
2) Using Custom site definitions
3) Programmatically
4) Using SharePoint Designer
Looking at your scenario, no 3 is an option. You may want to do it in the Feature Receiver itself.
I have a huge website (containing around 5000+) pages. There is a theme functionality in the website where user can choose different colors for their profile. Now i want to use the ASP.net theme feature and put different CSS (for different colors) in the theme folder and in Global.asax i want check the user theme and render appropriate link element with the css. But my problem is, i am not able to access the Page element for adding the link in the page.
Here is my code
Dim page As System.Web.UI.Page = TryCast(System.Web.HttpContext.Current.Handler,System.Web.UI.Page)
page.StyleSheetTheme = "Black"
But when i run this code I get a Null reference error.
P.s : My application is very huge so its not possible to have a master page or a base class and inherit it in every page.
Please suggest.
The page is not available in PreRequestExecute. This function is called before asp.net steps in to handle things, and asp.net is responsible for the page. Think of PreRequestExecute as being earlier in the scheme of things, like when IIS is first trying to figure out what to do with this thing it has, the thing is not even a page yet.
You might want to look into some of the other events that you can hook, there are events that would take place after the page has loaded that may allow you to do what you are suggesting.
Rather than going into global.asax for this, consider using master pages. One possibility is to have nested master pages, where the first master page sets up overall layout, and the nested master handles the theme. (Or one of several nested master pages, all referencing the same top-level master page). If necessary, you can use the PreInit event in the page to change master pages, and select the master that matches your theme selection.
You can centralize this function by having your own class that inherits System.Web.UI.Page, and have all your own pages inherit this new class. Handle the PreInit event there. (As well as other useful functions, like page-level handling of unhandled exceptions, general security issues, etc.
EDITED TO ADD: As #aepheus correctly notes, the page hasn't been instantiated at the PreRequestHandlerExecute event. So there's no page class you can access.