So I have an asp.net MenuItem user control created ( similar to what this post has ) within inside a MVC view. The user control works as expected, except the NavigateUrl.
This is the menuitem inside the usercontrol.
<asp:MenuItem Text="View Account" NavigateUrl="~/pages/account.aspx" />
The link looks fine if the user control is being rendered from a webform, it shows
http://localhost/SampleTest/pages/account.aspx
However, put the usercontrol inside the mvc view will have it rendered as
http://localhost/SampleTest/SampleTest/pages/account.aspx
There's an extra domain name "SampleTest" in the url.
What should I do to get rid of the extra domain name?
you need to update your URL navigation to URL.content.
<asp:MenuItem Text="View Account" NavigateUrl="#URL.content("~/pages/account.aspx")" />
code is not tested, but you can do like these.
Related
I am new to asp.net. So just learning everything step by step.
I have created a web project with the template.
On Page one, I have a button and a textbox with no action defined yet.
On Page two I have a button and a textbox and I also have db connections works from the button.
What I want to do is, if user writes something and click button on first page, I want to go page 2 and acts as clicked button.
I want to run some action on page two with parameter from page on.
I think this is possible with redireciton mechanism
I will post the code here. can anyone help me . I may be wrong as I am new to this language.
I can do it with a button but I want to do it with a asp link
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="BringPage2" />
Right now this is a link but I want to make it a button
<p>Bring Page 2 ยป<input id="txtBoxAlan" name="txtBoxAlan" type="text" />
Instead of redirect, I just used href as href="Default1.aspx"
I have Required field validators on some of my textboxes on some pages but when the user clicks on that page and then tries to click on a different page it wont let the user leave the page until the textboxes have been filled
How do i overcome this?
tries to click on a different page it wont let the user leave the page
I assume clicking on a different page requires the page to post back to server again.
If so, set the control's CausesValidation="False".
For example,
<asp:Button ID="Button1" runat="server" CausesValidation="False"/>
I am using the Login control. Just in FireFox, I am finding that I cannot click directly on the UserName field. I need to tab through all the other elements on that page. Just wondering if there is a work around to this issue?
<asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false" OnLoggedIn="LoginUser_LoggedIn">
You can do this by adding the following code to the Page_Load method on your login page:
AppLogin.Focus();
this.Form.DefaultButton = "ctl00$BodyPlaceHolder$AppLogin$LoginButton";
This will also cause the "login" button to be clicked when you click enter.
Note: The full "path" (ctl100$BodyPlaceHolder...) may vary slightly depending on whether or not you're using master pages, panels, etc. You can simply view the element on the page in your favorite inspector and find the rendered name for the login button.
More details can be found at my blog here.
I have a Contact userControl that have "save contact" as submit button and fields inside form tag we repeat this userControl with Code 20 times in one page
My problem is the Form Tag in the first userControl is hiding somehow --- i checked the userControl with developer Tool IE9 , firebug Firefox7 and the Form is not appearing in the first userControl and its appearing with the rest 19 Controls
I tried to View Source and take html copy in new html file in VS -- i found form is exist
i dont know if iam clear enough but please advice if you need more info
If you're running a form tag at the server, inside a user control, and then displaying this user control more than once on the page, then you will have multiple form tags running at server on one page, which is not allowed by ASP.NET
Take the form tag outside of the user control like:
<form runat="server">
<uc:Contact />
<uc:Contact />
<uc:Contact />
</form>
I had a asp.net Menu control on the master page and binded in the runtime based on the user access rights to the module. The problem I face is the MenuItemClick event is not fired when I view the website in the Internet Explorer(6.0). But the same is working fine in Firfox. I tried googling but none of the solutions worked for me. I was wondring if some one could help me to fix this.
There is no problem with Internet Explorer.
When you used MenuItem you probably used this form:
<asp:Menu ID="NavigationMenu" OnMenuItemClick="NavigationMenu_MenuItemClick" runat="server">
<items>
<asp:MenuItem Text="menuItem1" NavigateUrl="Web.aspx" />
<asp:MenuItem Text="menuItem2" NavigateUrl="otherWeb.aspx" />
</items>
</asp:Menu>
When you wrote in this form, the browser dosen't respect your event, because you gave it the URL to navigate to.
If you want that the browser will respect your event and handle it as well, you should delete the "NavigateUrl" attribute and it will work out.