CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 7/5/2005 1:03:49 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 22 Views: 295 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
23 Items, 2 Pages 1 2 |< << Go >> >|
chris1
Asp.Net User
How do you change default form name from "aspnetform" when using master pages?7/5/2005 1:03:49 AM

0/0

When i use master pages, i cannot get the form's name to be anything other than "aspnetform". I saw a post (http://forums.asp.net/929349/ShowPost.aspx) stating that you had to override the UniqueID. I tried doing this in the master and form pages, but i dont know if you have to be creating your own form and inherit from htlmform to make this hack work. I tried doing it in my "normal" form and it didnt work for me.

Any suggestions are appreciated,

Chris

 

Scott W
Asp.Net User
Re: How do you change default form name from "aspnetform" when using master pages?7/9/2005 9:01:01 AM

0/0

You are saying taht you can't put

<form id="whateveridiwant" runat="server">

junk

</form>

in your Master?

If you have form tags in the master, you don't need them in your other pages. Just put the form tags outside your content placeholders in the master and call it good. Works great.


Scott Willsey
chris1
Asp.Net User
Changing form id "aspnetForm" when using master pages7/9/2005 3:18:19 PM

0/0

Scott,

Thanks for your reply.

If you put the following form tag into the *<asp:content>* area of a page that's *using* a master page (Beta 2), then it will be rendered as follows:

Original:   <form id="whateveridiwant" runat=server>
Rendered: <form id="aspnetForm" method="post" action="somePage.aspx">

I hope that clarifies the problem,

Chris

MorningZ
Asp.Net User
Re: Changing form id "aspnetForm" when using master pages7/11/2005 12:04:12 AM

0/0

if i may just ask

why are you looking to change the id of it?  it's got to be unique no matter what, and its always going to be constant throughout the application... so why change it?


"If you make it idiot proof, they'll build a better idiot"
chris1
Asp.Net User
Re: Changing form id "aspnetForm" when using master pages7/11/2005 11:56:31 AM

0/0

The form id/name is used in an application that i'm porting. This app has much javascript that i'd prefer not to change, but i realize that i may have to if i cant discover a workaround to this bug soon.

Just for clarification, this is not the only form on a given page. I have a frmLeftNav, frmQuickSearch, frmMain, etc on given pages. It breaks my standards, javascript, coding style, and potentially introduces new bugs into already-proven production code to now have the maverick form id/name: "aspnetForm". Also note that the form to which i'm referring is not in the master page itself, but in the content area of a page using the master page.

Thanks for writing,

Chris
bhl
Asp.Net User
Re: Changing form id "aspnetForm" when using master pages7/17/2005 9:27:45 PM

0/0

you can create your own control and inherit it from HtmlForm, override the UniqueID attribute to return the control's ID instead of the uniqued id that's generated by asp.net.  works with asp.net 1.x
Lorddog
Asp.Net User
Re: Changing form id "aspnetForm" when using master pages6/13/2006 3:03:24 PM

0/0

sorry I have not found any workaround on this yet but here is the problem I see in their auto generating code. if you put for an example defaultFocus="myInput" into that form it will generate code to focus to that input using document.getElementById("myInput") and if you have other forms on the page with the same name you have a problem so you really need to add unique IDs to all your inputs in every form to make them unique (visual studios forces them to be unique but not to have to set them).

Also this seems important to me by the fact that someone else comes along and writes a content page and you dont want a conflict on a templated search form or nav form that he may not see at the time. I guess my suggestion is to make the IDs prefixed with the name on the form + the inputs name? Anyhow this seems enough problem to me as I may just handle all my forms myself.

Course the biggest problem here is if you have specific scripts to the name of your form and .net is changing your name on you, then you have to be aware of whats going on and might not be able to use runat="server" and the ispostback features.

Lorddog

Lorddog
Asp.Net User
Re: Changing form id "aspnetForm" when using master pages6/13/2006 3:53:44 PM

0/0

one other thing I just thought of. you may want that form object and if they change the names again or whoknows what may happen in the future, so you may want that form object to do an auto loop of all the elements in your form (which may be dynamically built so you dont know the specific names).

well the way to do it is to put a unique hidden input in your form and get that input and then just add a .form call off of it and now you have a reference to your form without knowing the name of your form or which item in the forms array it might be.

Lorddog

KCrow
Asp.Net User
Re: Changing form id "aspnetForm" when using master pages5/10/2007 4:09:52 PM

0/0

Not only does it change the ID of the form in the master it also changes the action that is associated. Can someone confirm this bug and give us a viable solution to this?

 

<Code>

<

form id="MainSiteForm" Name="MainSiteForm" ClientID = "MainSiteForm" runat="server" method="post" action="~/Products/SearchResults.aspx">

</code>

 

Rendered:

 <form name="aspnetForm" method="post" action="default.aspx" id="aspnetForm" ClientID="MainSiteForm">


-------------------------
Do What Thou Wilt...
KCrow
Asp.Net User
Re: Changing form id "aspnetForm" when using master pages5/10/2007 4:11:11 PM

0/0

Not only does it change the ID of the form in the master it also changes the action that is associated. Can someone confirm this bug and give us a viable solution to this?

 

<Code>

<

form id="MainSiteForm" Name="MainSiteForm" ClientID = "MainSiteForm" runat="server" method="post" action="~/Products/SearchResults.aspx">

</code>

 

Rendered:

 <form name="aspnetForm" method="post" action="default.aspx" id="aspnetForm" ClientID="MainSiteForm">


-------------------------
Do What Thou Wilt...
himawari
Asp.Net User
Re: How do you change default form name from "aspnetform" when using master pages?5/11/2007 1:21:33 AM

0/0

First, you will need to remove your form tag within your content.

Write a javascript file and include it to your content page. You may add it to your page by using

 

ClientScript.RegisterClientScriptInclude("common", ResolveUrl("~/js/common.js"));
 Your javascript file should contain a javascript functions that changes the form's id:
function onSubmit() {
document.forms[0].Id = 'YourId';
}
 

Then, you will need to use a button or imagebutton (or any elements that support the postbackrul property) 

<asp:ImageButton onClientClick="onSubmit();"  ImageUrl="images/submit.gif" id="submitButton" runat="server" PostBackUrl=http://www.yourdomain.com/form.aspx />

 

 


Eric on Web Development
Lorddog
Asp.Net User
Re: How do you change default form name from "aspnetform" when using master pages?5/11/2007 12:20:26 PM

0/0

why not just take the runat="server" off the tag and handle the postback the old fashion way, by checking the request.form object?

 

Lorddog

KCrow
Asp.Net User
Re: How do you change default form name from "aspnetform" when using master pages?5/11/2007 2:41:18 PM

0/0

I use Ajax controls in my site as well which require that the runat=server attribute be set for the script manager.  I really don't mind the name changing, since i don't request it.. My real issue is that it also changes the Action attribute and does not submit it to the searchresults.aspx page as intended.
-------------------------
Do What Thou Wilt...
gpowell
Asp.Net User
Re: How do you change default form name from "aspnetform" when using master pages?5/18/2007 9:33:59 PM

0/0

Hi there... did you ever figure this out?  I'm running into the exact issue.  Any help you can provice would be much appreciated.  Thanks!

gpowell
Asp.Net User
Re: How do you change default form name from "aspnetform" when using master pages?5/18/2007 10:01:51 PM

0/0

I just figured it out... let me know if you are interested in the solution...

Lorddog
Asp.Net User
Re: How do you change default form name from "aspnetform" when using master pages?5/20/2007 9:13:49 PM

0/0

well I dont use forms with runat server but I feel it is always better to know what is going on and why so if you can indulge us, pls let us know.

 

Lorddog

gpowell
Asp.Net User
Re: How do you change default form name from "aspnetform" when using master pages?5/21/2007 2:48:01 PM

0/0

I should note that I'm using isapi_rewrite for url rewriting...

I get part of my solution from the "Handling ASP.NET PostBacks with URL Rewriting" of http://aspalliance.com/1234_TipTrick_Url_Rewriting_with_ASPNET.  However I modified the WriteAttribute method because the Request.RawUrl grabs the re-written url, not the original.  Here's the code for getting the original--again, this is only for isapi_rewrite.
                if (Context.Items["ActionAlreadyWritten"] == null)
                {
                    int loop1, loop2;
                    System.Collections.Specialized.NameValueCollection coll;
                    bool canBreak = false;
                    // Load Header collection into NameValueCollection object.
                    coll = Context.Request.Headers;

                    // Put the names of all keys into a string array.
                    String[] arr1 = coll.AllKeys;
                    for (loop1 = arr1.Length-1; loop1 >= 0; loop1--)
                    {
                        if (arr1[loop1] == "X-Rewrite-URL")
                        {
                            String[] arr2 = coll.GetValues(arr1[loop1]);
                            for (loop2 = 0; loop2 < arr2.Length; loop2++)
                            {
                                value = Context.Server.HtmlEncode(arr2[loop2]);
                                Context.Items["ActionAlreadyWritten"] = true;
                                canBreak = true;
                                break;
                            }
                            if (canBreak)
                                break;
                        }

                    }
                }

 Here's the code I have in my MasterPage to fix the App_Themes issue.

public void Page_Load(object s, EventArgs e)
{
    HtmlHead myHead = (HtmlHead)FindControl("Header");
    HtmlLink myLink = new HtmlLink();
    foreach (HtmlControl c in myHead.Controls)
    {
        if (c.GetType() == myLink.GetType())
        {
            myLink = (HtmlLink)c;
            if (myLink.Href.Contains("App_Themes"))
            {
                string href = myLink.Href;
                href = href.Remove(0, href.IndexOf('A', 0));
                myLink.Href = "/" + href;
            }
        }
    }
}
 
jude_44
Asp.Net User
Re: How do you change default form name from "aspnetform" when using master pages?5/21/2007 2:59:43 PM

0/0

Please could you drop me a note with whatever you figured out about this?

Am pretty stuck at the moment....

Thanks in advance,

Dave

KCrow
Asp.Net User
Re: How do you change default form name from "aspnetform" when using master pages?5/25/2007 5:52:12 PM

0/0

Yes please post your findings.. Thanks


-------------------------
Do What Thou Wilt...
prutins
Asp.Net User
Re: How do you change default form name from "aspnetform" when using master pages?6/1/2007 6:00:23 PM

0/0

I'm also looking for a way to control the id of the rendered form, for integrating with an older site.  I haven't found anything yet!  However, it sounds like you might benefit from the PostBackUrl attribute of your submit control.  The default submit behavior is to post to the script specified in the form's action attribute.  PostBackUrl allows it to post to whatever other script you specify.

Both methods actually use a client-side javascript method to do the actual form submission.

This topic may also be of interest.

Hope that helps!
 

23 Items, 2 Pages 1 2 |< << Go >> >|


Free Download:


Web:
How do you change default form name from "aspnetform" when using ... How do you change default form name from "aspnetform" when using master pages?, > ROOT > NEWSGROUP > Asp.Net Forum ...
How do you change default form name from "aspnetform" when using ... How do you change default form name from "aspnetform" when using master pages? Last post 07-31-2007 6:33 AM by jude_44. 22 replies. Sort Posts: ...
How to change default form name "aspnetForm" in Beta 2? - ASP.NET ... How to change default form name "aspnetForm" in Beta 2? ..... solves the original problem of having all forms on pages using Master Pages ID'd " aspnetForm", ...
aspnetform and master pages Default aspnetform and master pages. Does anyone know how to get a form's name to be anything other than "aspnetform" when using master ...
aspnetform and master pages Does anyone know how to get a form's name to be anything other than "aspnetform" when using master pages? Thanks, ... id/name -- on the client side. I prefer not to have to change the form id/name all over the place if i ...
change default name of the form block : aspnetform, change, name, form is it possible to change the default name .net 2.0 gives to the form block. no ... 1, Create an Oracle Forms data block using a stored procedure ยท Oracle .... when i use master pages, the form is on a master page and in view page source ...
aspnetForm Problems - ng.asp-net-forum ... aspnetForm Problems, > ROOT > NEWSGROUP > Asp.Net Forum ... the original problem of having all forms on pages using Master Pages ID'd "aspnetForm", ... How do you change default form name from "aspnetform" when using . ...
MasterPages & aspnetForm Jun 5, 2006 ... Is there anyway to force a master page to retain the name of the form as ... programmed instead of changing it to aspnetForm? ... I have a certain degree of sympathy with this ... that's what I expect the ID of the form to be, not " aspnetForm". ... "aspnetform" when using master pages? ... Brent . ...
AJAX Not working in Particular Masterpages masterpages. This step was necessary, otherwise the validation tool ... ...
aspnetForm Default aspnetForm. How do I assign a name to the form element in a master page/ ... controls (in favor of straight HTML), however, the use of master pages ...




Search This Site:










how to redirect missing pages to a new page?

cannot find tables in sql server

checkbox in treeview

dynamic menus

dotnetnuke.com skin available?

listbox binding xml error.

problems with web.config

solpartmenu - fix for firefox with upgraded browsercaps

create an xml feed for your photo gallery

either vb scripting or .net web form designer

executing a sp via vs2005

referencing login username in code behind

open csproj file in visual studio c# express edition

asp.net 1.1 not running on visual studio.net 2003

authentication and session_start

what is a region?

question regarding to web site administration toolkit

recordset = nothing

can i share code from another proj w/o copying?

new to programing..?

tabbed web part of different user controls?

gallery install problem

declare variables inside/outside main code block

beginning asp.net

full control

asp.net profile expanderpanel

creat user problem in beta 2 (invalid password all the time)

webservices access denied problem

new module - create and share!

dnn 310 - custom controlpanel

 
All Times Are GMT