Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to force control name on client side 1

Status
Not open for further replies.

NeilTrain

Programmer
May 27, 2003
275
US
I have an asp.net app, that when it's finished walking the user through a process, submits a form to a legacy(non .net) app which needs email and password parameters.

The problem is the controls get renamed the something like CTL$MAIN$email and CTL$MAIN$password

How can I force them to stay just email and password?
 
you can't. client markup is autogenerated by asp.net. if you could override them then 2 controls could have the same id and the system would crash.

the only way to get 1:1 naming from client to server is to place all the controls on a webform that doesn't inherit from another page, and doesn't use master pages, user controls, or repeatable controls (gridview, repeater, formview, detailsview)

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
muhahah, "can't" isn't in my vocabulary!

found this neat little enum called LiteralMode.PassThrough, that paired with Button.PostBackUrl and Button.UseSubmitBehavior = true properties and cha-ching, we're in business :)

Code:
<asp:Literal ID="litSubmit" runat="server"></asp:Literal>
<asp:Button ID="btnSiteLink" runat="server" Text="Click here to continue." Visible="false" />

and in the code behind:
Code:
btnSiteLink.Visible = true;
btnSiteLink.PostBackUrl = prj.Site.SiteURL.Replace("&amp;", "&");
btnSiteLink.UseSubmitBehavior = true;

litSubmit.Mode = LiteralMode.PassThrough;
litSubmit.Text = "<input type=\"Hidden\" name=\"email\" value=\"" + prj.AuthorEmail + "\">";
litSubmit.Text += "<input type=\"Hidden\" name=\"password\" value=\"" + prj.AuthorPassword + "\">";

and the html output:
Code:
<input type="Hidden" name="email" value="neiln@...">
<input type="Hidden" name="password" value="...">
 
a star for you. i did not know about this feature. I would use this with caution though, as it could be very easy to duplicate ids on the client.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top