MSCRM Sitemap link to .htm page. How do I pass parameters? - c#

I have a Site Map link that opens up a Web Resource .htm page. Everything works great except I want to pass some values to that page. I assumed I could pass them as a querystring since there is the Xrm.Page.context.getQueryStringParameters() method but my querystring seems to get stripped out.
<SubArea Icon="$webresource:my_webresourceicon.gif"Id="nav_my_webresourceid" Url="$webresource:my_webresourcepage.htm?xyz=123" Client="All" AvailableOffline="false" Title="My Web Resource Page" Description="My Web resource Description" Sku="All" PassParams="true"/>
I want to be able to access the parameter xyz from my_webresourcepage.htm as the page loads. What is the best way to go about passing this value?
Thanks

Unfortunately you can't pass xyz unless you modify the registry. Instead, you want to use the parameter "data".
http://msdn.microsoft.com/en-us/library/gg309536.aspx

Related

ASP.NET Web Forms - How to redirect and pass parameters without problems

I wanted to redirect (by code) to another ASPX page and on that page I wanted to select the appropriate view (in a multi-view and during page load).
My solution was to add a url parameter that was checked on the "OnLoadComplete" event and take appropriate action, but it seems that this url parameter gets copied to all the links on the page. So, the user cannot navigate anywhere else because always this view gets presented.
My second thought was to use a Session variable, but I am afraid that this will be an overkill.
Any ideas/thoughts/suggestions on this matter?
Can I prevent the use of the url parameter in all the page-links?
Is it bad if I use a Session variable for this temporarily?
Is there some other way to do this?

How can I get the part of the URL that is getting changed whenever I clicked on some link?

My home page is :
http://localhost:8089/AFPWeb4.0/Project/ProjectList.aspx?StartPage=1
I have a link ProjectListInProjectGroups . When a user clicks on that link, my URL is changed to
http://localhost:8089/AFPWeb4.0/ProjectListInProjectGroups.aspx?
How can I get part of the URL that is changed ?
I need this value ProjectListInProjectGroups. I want to get this value in a ascx page.
Can someone help on this?
You can pass the current URL to the next page as a parameter and then you can find the difference between the two URLs using string operations.
If in your console you type window.location.pathname you would get the route after host name.
In console just type window.location and you can see what properties that has.

How can I pass textbox value from usercontrol(ascx) to another page (aspx) using Server.Transfer()

I am writing one user control (webpart) in kentico. I want to pass textboxes' value from usercontrol to aspx page using Server.Transfer().
Can it be? If so, how can I do like that?
Best Regards,
Reds
I don't particularly like this method, I prefer to use Sessions to pass data between pages, but if you need to do this here how it's done according to the this page.
Here's TL;DR summary. It requires three scripts/pages:
Form.ascx - this will be the control that contains the text box value.
FormParsingScript.aspx (referenced in the Form.ascx in the Action attribute) - this will perform the actual Server.Transfer "FinalScript.aspx" call
FinalScript.aspx which will display the contents of Response.Form["TextBoxName"] (HTTP POST) or Response.QueryString["TextBoxName"] (HTTP GET)

Dynamic Pages From a Database in C#

Forgive me if this has already been asked somewhere, but I cannot figure out the best way to accomplish this task. I want to be able to create a rendering system that will allow me to render out content from thousands of different .aspx pages without having to create thousands of .aspx pages. That being said, I still want to be able to render out the appropriate .aspx page if it exists in my code.
For example, when a request is made to the site, I want to check and see if that URL is in the database, if it is, then I want to render the content appropriately. However, if it doesn't, then I want it to continue on to rendering the real .aspx page.
In trying to use an HTTPModule, I cannot get the page that exists in the database to write out the appropriate content. Here's my code.
void context_BeginRequest(object sender, EventArgs e)
{
HttpApplication application = sender as HttpApplication;
Uri url = application.Context.Request.Url;
//Checks to see if the page exists in the database
PageInformation page = PageMethods.GetPageFromUrl(url.AbsolutePath);
if (page != null)
{
string renderedPage = Renderer.RenderPage(page);
application.Context.Response.Write(renderedPage);
}
}
However, when trying to use an HTTPHandler, I can't get the real .aspx pages to render appropriately because the *.aspx verb is being dealt with by the handler.
If anyone has any better ideas on how to completely re-design this, I'm completely open to that as well. Thanks.
This will do the trick:
Type page_type = BuildManager.GetCompiledType ("~/page.aspx");
Page page = (Page) Activator.CreateInstance (page_type);
page.ProcessRequest (Context);
I think you're lookign for a simple URL rewriting example.
So you have a single page "default.aspx" that could take an argument of the content you want to display "default.aspx?page=home", but you don't want the nasty query string part "?page=home".
this is best solved by URL rewriting which can be used as an ISAPI module in IIS. So instead of the URL string above, people see a page called "home.aspx", and the web server translates this into "default.aspx?page=home" for your page which can go get the content for the "home" page out of the DB and display it on the screen.
Here's a page with more information on a good implementation of this process:
http://www.opcode.co.uk/components/rewrite.asp
I believe this shows how to process the "normal" pages inside a handler
other example

How do I redirect to a website using MVC?

I am having a hard time figuring out how to redirect to an outside source.
in my code, I have
<%= Html.ActionLink("New Name Search", "Index") %>
which will allow me to navigate within the code.
how do I redirect to ...google for example?
google
The purpose of the ActionLink helper is to generate links that will direct the user to a controller action that you've defined.
If you want to navigate the user to an outside source you should just use a regular anchor tag.
Response.Redirect("http://google.com/");
(It's not really MVC-specific, by the way)
If you are redirecting from your controller (or action filter, etc.) you can use the RedirectResult as your ActionResult type:
RedirectResult("http://www.google.com");
This is essentially doing a Response.Redirect, but is the preferred way of sticking with ASP.NET MVC conventions.
If you are just creating a link inside a View, just use Click to go to Google.
"Redirecting" means many things.
If you just want to show a link that redirects the user to another URL you can use the anchor tag normally in you templates.
google
Now, if you want to redirect the user within the controller, call the Redirect Method.
Result("http://www.google.com");

Categories

Resources