Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Thursday, March 29, 2012

passing values

is there a way to choose which values to
pass to the server when a form is submited?For each form field in the form, a value will be passed.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"rpp" <rpsur@.yahoo.com> wrote in message
news:8fccfb65.0312110716.52e2e776@.posting.google.c om...
> is there a way to choose which values to
> pass to the server when a form is submited?

Passing values between client and server side (Javascript to C#)

I would like to access client side values from the code behind.

Say I open a window like this

 popWindow = window.open("data_list.aspx","dataWindow",'toolbar,width=150,height=100')
 How can I get the window name "dataWindow" from that current window or the parent window?
 Any other examples accessing variables between server side (C#) and client side (JavaScript) would be greatly appreciated.
 Regards -WH 

Page.Request.ServerVariables["SCRIPT_NAME"] will get the name of the current page. You can also pass values in a querystring, which will make them accessible to server-side code.
thanks, Page.Request.ServerVariables["SCRIPT_NAME"] worked out for me.

Passing Values Between Web Forms Pages

I am porting an old client/server application to asp.net. I used to
retrieve data into local tables (Paradox table-files on the client's
disk) and work on them before saving them back to the server. What is
the approach for this in asp.net? The comments in MSDN on using the
session object are scary, imagining that several users at the same
time will use plenty of space on the server's memory! Or is it
realistic to memorize the data in a page and access them from the
following pages?
Thank for your help!You can add objects to the HttpContext of the current Page, and then use
Server.Transfer to transfer to the next page. The HttpContext is transferred
as well, and you can pull the data from the original page out of that.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big things are made up of
lots of little things.

"cgia" <cgian31@.katamail.com> wrote in message
news:b35db8fd.0307250620.7aed635b@.posting.google.c om...
> I am porting an old client/server application to asp.net. I used to
> retrieve data into local tables (Paradox table-files on the client's
> disk) and work on them before saving them back to the server. What is
> the approach for this in asp.net? The comments in MSDN on using the
> session object are scary, imagining that several users at the same
> time will use plenty of space on the server's memory! Or is it
> realistic to memorize the data in a page and access them from the
> following pages?
> Thank for your help!
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/i...te/default.aspx

http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetjunkies.com/tutori...?tutorialid=600

http://www.dotnetbips.com/displayarticle.aspx?id=79

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net

"cgia" <cgian31@.katamail.com> wrote in message
news:b35db8fd.0307250620.7aed635b@.posting.google.c om...
> I am porting an old client/server application to asp.net. I used to
> retrieve data into local tables (Paradox table-files on the client's
> disk) and work on them before saving them back to the server. What is
> the approach for this in asp.net? The comments in MSDN on using the
> session object are scary, imagining that several users at the same
> time will use plenty of space on the server's memory! Or is it
> realistic to memorize the data in a page and access them from the
> following pages?
> Thank for your help!
There are a lot of options to transferring values between pages: Session
like you've mentioned, The querystring (of course), But you may want to look
into Server.Transfer and the Context Object.

I hope this leads you in the right direction.

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"cgia" <cgian31@.katamail.com> wrote in message
news:b35db8fd.0307250620.7aed635b@.posting.google.c om...
> I am porting an old client/server application to asp.net. I used to
> retrieve data into local tables (Paradox table-files on the client's
> disk) and work on them before saving them back to the server. What is
> the approach for this in asp.net? The comments in MSDN on using the
> session object are scary, imagining that several users at the same
> time will use plenty of space on the server's memory! Or is it
> realistic to memorize the data in a page and access them from the
> following pages?
> Thank for your help!
Actually what I want to transfer between forms is huge tables... do
you think it is appropriate to use the server.transfer?

cgian31@.katamail.com (cgia) wrote in message news:<b35db8fd.0307250620.7aed635b@.posting.google.com>...
> I am porting an old client/server application to asp.net. I used to
> retrieve data into local tables (Paradox table-files on the client's
> disk) and work on them before saving them back to the server. What is
> the approach for this in asp.net? The comments in MSDN on using the
> session object are scary, imagining that several users at the same
> time will use plenty of space on the server's memory! Or is it
> realistic to memorize the data in a page and access them from the
> following pages?
> Thank for your help!
Yes, that seems like one of the more efficient solutions for this particular
problem.

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net

"cgia" <cgian31@.katamail.com> wrote in message
news:b35db8fd.0307251918.2ad13d06@.posting.google.c om...
> Actually what I want to transfer between forms is huge tables... do
> you think it is appropriate to use the server.transfer?
>
> cgian31@.katamail.com (cgia) wrote in message
news:<b35db8fd.0307250620.7aed635b@.posting.google.com>...
> > I am porting an old client/server application to asp.net. I used to
> > retrieve data into local tables (Paradox table-files on the client's
> > disk) and work on them before saving them back to the server. What is
> > the approach for this in asp.net? The comments in MSDN on using the
> > session object are scary, imagining that several users at the same
> > time will use plenty of space on the server's memory! Or is it
> > realistic to memorize the data in a page and access them from the
> > following pages?
> > Thank for your help!

Passing values from client 2 server

Hi,

Simple question:

Is there a way to a value from client-side to server-side upon a click?

function _getReport(ReportName) { alert(ReportName); }

<asp:datalist id="dlReports" runat="server">
<itemtemplate>
<img height="7" src="http://pics.10026.com/?src=../ReportsImages/navlink.gif" width="5">
<a class="Normal" id="<%#
DataBinder.Eval(Container.DataItem,"Description") %>"
href="ReportMainPage.aspx" onclick="return _getReport('<%#
EncryptString(DataBinder.Eval(Container.DataItem,"Description"))%>');">
<%# DataBinder.Eval(Container.DataItem,"Description") %></a>
</itemtemplate>
</asp:datalist
What I would like to accomplish is to pass the report name to server-side
from client-side upon clicking on a link above.

YamaSomething like, create a hyperlink column in a DataSet and capture the value
sent when the person clicks? There are a variety of other controls,
LinkButton, et al, you can use, as well. Repeater is often better, as you
have more flexibility, but it really depends on what you need.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Yama" <ykamyar@.grandpacificresorts.com> wrote in message
news:ePgR80%230DHA.1740@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Simple question:
> Is there a way to a value from client-side to server-side upon a click?
> function _getReport(ReportName) { alert(ReportName); }
> <asp:datalist id="dlReports" runat="server">
> <itemtemplate>
> <img height="7" src="http://pics.10026.com/?src=../ReportsImages/navlink.gif" width="5">
> <a class="Normal" id="<%#
> DataBinder.Eval(Container.DataItem,"Description") %>"
> href="http://links.10026.com/?link=ReportMainPage.aspx" onclick="return _getReport('<%#
> EncryptString(DataBinder.Eval(Container.DataItem,"Description"))%>');">
> <%# DataBinder.Eval(Container.DataItem,"Description") %></a>
> </itemtemplate>
> </asp:datalist>
> What I would like to accomplish is to pass the report name to server-side
> from client-side upon clicking on a link above.
> Yama
Hi Greg,

Thank you for your reponse. I would like, once the list is generated, to
capture the (<%# DataBinder.Eval(Container.DataItem,"Description") %>)
report name every time the user clicks on a link.

How can I do that using LinkButton?

Yama

"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@.comcast.netNoSpamM> wrote in
message news:Ouy2l6%230DHA.832@.TK2MSFTNGP09.phx.gbl...
> Something like, create a hyperlink column in a DataSet and capture the
value
> sent when the person clicks? There are a variety of other controls,
> LinkButton, et al, you can use, as well. Repeater is often better, as you
> have more flexibility, but it really depends on what you need.
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> ************************************************** ********************
> Think Outside the Box!
> ************************************************** ********************
> "Yama" <ykamyar@.grandpacificresorts.com> wrote in message
> news:ePgR80%230DHA.1740@.TK2MSFTNGP12.phx.gbl...
> > Hi,
> > Simple question:
> > Is there a way to a value from client-side to server-side upon a click?
> > function _getReport(ReportName) { alert(ReportName); }
> > <asp:datalist id="dlReports" runat="server">
> > <itemtemplate>
> > <img height="7" src="http://pics.10026.com/?src=../ReportsImages/navlink.gif" width="5">
> > <a class="Normal" id="<%#
> > DataBinder.Eval(Container.DataItem,"Description") %>"
> > href="http://links.10026.com/?link=ReportMainPage.aspx" onclick="return _getReport('<%#
> > EncryptString(DataBinder.Eval(Container.DataItem,"Description"))%>');">
> > <%# DataBinder.Eval(Container.DataItem,"Description") %></a>
> > </itemtemplate>
> > </asp:datalist>
> > What I would like to accomplish is to pass the report name to
server-side
> > from client-side upon clicking on a link above.
> > Yama

Monday, March 26, 2012

passing values in html

Is this the right way topass values to query string
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/Admin.aspx?Token=ABC">Go To Admin Page</asp:HyperLink></div>"bobby" <bobby@.discussions.microsoft.comwrote in message
news:5BD2FD98-37E7-4311-A29A-F82D26B80CC2@.microsoft.com...

Quote:

Originally Posted by

Is this the right way to pass values to query string
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/Admin.aspx?Token=ABC">Go To Admin
Page</asp:HyperLink></div>


Yes, assuming there is an opening <divtag a bit further up...

--
Mark Rae
ASP.NET MVP
http://www.markrae.net
There is more than one "right way" to do this kind of thing, but the
technique you've shown is indeed valid.

Here are some other ways to pass data around too:
http://SteveOrr.net/articles/PassData.aspx
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"bobby" <bobby@.discussions.microsoft.comwrote in message
news:5BD2FD98-37E7-4311-A29A-F82D26B80CC2@.microsoft.com...

Quote:

Originally Posted by

Is this the right way topass values to query string
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/Admin.aspx?Token=ABC">Go To Admin
Page</asp:HyperLink></div>

Passing values into SQL Server

Hi: I create two textboxes and a button and try to pass values from the
textboxes into SQL Server by using Save Button Can any one please tell
me do i write some code on save button or i bind the textbox with the
SQL Server fields as i bind the fields in VB.NET

Thanks,Few controls have automagic binding in a web app. Try something like this:

Dim textbox1Value as TextBox1.Text
Dim textbox2Value as TextBox2.Text

Dim sql as String = "INSERT INTO SomeTable VALUES (@.Val1, @.Val2)"
Dim conn As New SqlConnection("Your Connection string Here")
Dim cmd as New SqlCommand(sql, conn)

Dim param1 As new SqlParameter("@.Val1", SqlDbType.VarChar, 50)
Dim param2 As new SqlParameter("@.Val2", SqlDbType.VarChar, 50)

cmd.Parameters.Add(param1)
cmd.Parameters.Add(param2)

Try
conn.Open()
cmd.ExecuteNonQuery()
Catch ex As Exception
'Not sure how you want to handle exceptions
Finally
conn.Dispose()
End Try

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
********************************************
Think outside the box!
********************************************
<colleen1980@.gmail.comwrote in message
news:1165317810.925443.207280@.79g2000cws.googlegro ups.com...

Quote:

Originally Posted by

Hi: I create two textboxes and a button and try to pass values from the
textboxes into SQL Server by using Save Button Can any one please tell
me do i write some code on save button or i bind the textbox with the
SQL Server fields as i bind the fields in VB.NET
>
Thanks,
>

Passing values into SQL Server

Hi: I create two textboxes and a button and try to pass values from the
textboxes into SQL Server by using Save Button Can any one please tell
me do i write some code on save button or i bind the textbox with the
SQL Server fields as i bind the fields in VB.NET
Thanks,Few controls have automagic binding in a web app. Try something like this:
Dim textbox1Value as TextBox1.Text
Dim textbox2Value as TextBox2.Text
Dim sql as String = "INSERT INTO SomeTable VALUES (@.Val1, @.Val2)"
Dim conn As New SqlConnection("Your Connection string Here")
Dim cmd as New SqlCommand(sql, conn)
Dim param1 As new SqlParameter("@.Val1", SqlDbType.VarChar, 50)
Dim param2 As new SqlParameter("@.Val2", SqlDbType.VarChar, 50)
cmd.Parameters.Add(param1)
cmd.Parameters.Add(param2)
Try
conn.Open()
cmd.ExecuteNonQuery()
Catch ex As Exception
'Not sure how you want to handle exceptions
Finally
conn.Dispose()
End Try
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
****************************************
****
Think outside the box!
****************************************
****
<colleen1980@.gmail.com> wrote in message
news:1165317810.925443.207280@.79g2000cws.googlegroups.com...
> Hi: I create two textboxes and a button and try to pass values from the
> textboxes into SQL Server by using Save Button Can any one please tell
> me do i write some code on save button or i bind the textbox with the
> SQL Server fields as i bind the fields in VB.NET
> Thanks,
>

Saturday, March 24, 2012

Passing variables between Server scripts and client scripts!

Hi,

I am having difficulty in passing a variable from a server script to a client script. I am looking to take a parameter that is passed into an ASP page from another page and use this parameter in a client side script.Is it possible to do this?? A simplified version of what I want to do is:

<%
Dim Tag
Tag = Request.QueryString("ID")
%>
........

<%Script Language="VBScript">
Dim Tag2
Tag2 = <%=Tag%>
document.write(Tag2)
<Script
Any help greatly appreciated!!1. need quotes around the literal value in client script
2. need to close your Script tag

<%
Dim Tag as String = Request("ID")
%
<Script Language="VBScript">
Dim Tag2
Tag2 = "<%= Tag %>"
document.write(Tag2)
</Script>

Thank you very much!! Works a treat.

Passing variables between pages [CASE CLOSED]

Hi,
I just wanted to know how can i pass my variables from one web page to the other?
For example, I want to pass the server string on the 1st page to other pages. How do i go around doing it?
Pls helpPassing Parameteres from One Page to another (http://aspnet.4guysfromrolla.com/articles/020205-1.aspx)
Thanks a lot Ali. But I don't really understand C#. Is it possible to explain in VB codes? :blush:
Thanks a lot Ali. But I don't really understand C#. Is it possible to explain in VB codes? :blush:
Ok the easiest way to pass data between pages is to use Query String. Suppose you have two variables ([i] firstName and lastName[i]) on Page1 and you want to pass them onto page2, then on Page1 you can build a url like this Dim redirectUrl As String
redirectUrl = "Page2.aspx?firstName=" & firstName & ";&lastName=" & lastName" And then use the redirect method of response like this Response.Redirect(redirectUrl) And in page2 you can access the querystring variables like this Request.QueryString("firstName")

Does this make any sense?
Ideally, connection strings should be held in the web.config file, which looks something like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation defaultLanguage="vb" debug="true" />
</system.web>
<appSettings>
<add key="ConnectionInfo" value="server=(local);database=Northwind;Integrated Security=SSPI;uid=sa;pwd=sa;" />
</appSettings>
</configuration>

You need to replace the value of the ConnectionInfo key with your own connection string (and you'll probably want to turn debug off at some point, bearing in mind that the settings in this file apply to all of your pages).

You then retrieve this value in your pages using:
ConfigurationSettings.AppSettings("ConnectionInfo")

However, to just pass the contents of a variable (eg. strForeName = "Jim", strSurname = "Jones"), then you can use the QueryString.

First, when you want to get to the new page, you use:
Response.Redirect("some_page.aspx?forename=" & strForeName & "&surname=" & strSurname)

These variables can then be retrieved in some_page.aspx using this syntax:

Dim strForeName As String = Request.QueryString("forename")
Dim strSurname As String = Request.QueryString("surname")

This can be extended for more variables just by extending the line you use when you redirect to some_page.aspx (eg. "some_page.aspx?var1=value&var2=value&var3=value"). Note the use of the question mark for the first value and ampersand for the following values.
Thanks a lot dude! You really solved my problem.
Greatest thanks to Ali. You're the man! :bigyello: :bigyello:

Wednesday, March 21, 2012

passing variables to a server control

Hi,

I'm maintaining a website with alot of files, and every page uses server controls for both the header and the footer. On some of the pages I don't want to show part of the header, however I am still including the header. The only way I can think to do this is to have a seperate header for the pages I want to display different . This is a major pain if I have to do it this way. Is there anyway I can pass a variable to the header server control ? I'd love to pass an "on" or "off" and display the part of the header accordingly. This is what my relevant parts of my page look like on every page

<%@dotnet.itags.org.RegisterTagPrefix="abc"TagName="myHeader"Src="../includes/myHeader.ascx" %>

<html>

<body>

<abc:myHeaderrunat="server"id="myHeader"/>

...........

</body>

</html>

If you have source access to your header/footer server control, then you can create a property called something like 'DisplayMode' and assign it with a default value, i.e.: ON. And inside these controls, do a check on the mode what to display.

Your server control on the page files would be look like:

<abc:myHeader runat="server" id="myHeader" DisplayMode="Off" />

hi Jack,

This sounds great. How would I go about creating the property? Could you possibly give me an example ? :)

Much appreciated,

mikeg123


Hi,

Well I think you can do it in various ways.

1. Make some public properties within your UserControl and the pages where you don't want to use certain areas make them invisible through the properties.
2. You can write some code in your Web user control in which you can check the current URL and make the portion available or not available. You can get the current url by Request.Path.ToString(); But for sure this method will be a lengthy one because you have to mention all the url's for which you want to make changes in the header.
3. You can pass a query string variable and check it on the UserControl's load event with Request.QueryString["variableName"]. I think this would be a reasonable way because for certain situations you just have to pass the value in the query string variable and you write code in the user control to handle the situation.

These are the possible ways that I can advise you there might be more.

I hope it will solve your problem

Thanks and best regards,


#2 & #3 wont work for me, however your first suggestion sounds great

I have created this property in the user control, but I'm not sure how I am supposed to access the information I am passsing ?

PublicProperty displayBanner()

Get

EndGet

Set(ByVal value)

EndSet

EndProperty

thanks very much!!


Example in c#:

public class myHeader{// private fieldsprivate string _displayMode ="On";// you can work little more to create an Enum to limit types ...// public propertypublic string DisplayMode {set {if (!string.IsNullOrEmpty(value)) { _displayMode =value; } } } ...// eventsprotected void OnLoad() {if (string.Compare(_displayMode,"off",true) == 0) {// hide control }else if (string.Compare(_displayMode,"alternate",true) == 0) {// display an alternate view }else {// show up normally } }}

Hi Jack,

You wouldnt be able to give me one in VB would you? I apologize for not specifying before, I thought I would be able to convert it, but this is pretty confusing for me.

Very much appreciated, have a good day!

Thanks again,

hehe, I'm not a VB.NET developer. however, I've converted to VB.NET, let me know if it works. I think you should get the idea at least.

Public Class myHeader' private fieldsPrivate _displayModeAs String ="On"' you can work little more to create an Enum to limit types ...' public propertyPublic WriteOnly Property DisplayMode()As String Set (ByVal ValueAs String)If Not String.IsNullOrEmpty(value)Then _displayMode = valueEnd If End Set End Property ...' eventsProtected Sub OnLoad()If String.Compare(_displayMode,"off",True) = 0Then' hide controlElse If String.Compare(_displayMode,"alternate",True) = 0Then' display an alternate viewElse' show up normallyEnd If End SubEnd Class

awesome thanks so much it worked!!

this is a problem ive been pushing under the rug for literally two years, much apprecaited !

Passing windows credentials from server to server.

Hello,

I have been desperately trying to programmatically authenticate a windows
user, create their credentials, and then redirect them to a different server
while passing the credentials at the same time so that they don't have to
login again.

Specifically, I have two webservers in the same domain. When I have a user
go to Webserver A (which uses basic authentication) I programmatically
create either a user credential or impersonate a user context (for now it's
hardcoded, but in the future it would be entered in forms). Then, I want to
let that user access a page on Webserver B (which uses basic
authentication), but I don't want them to have to login again -- rather, I
want to use the user context that I programmatically created on Webserver A.

For instance, here is an example of the code I use to create the user
credentials:

Dim strURI = "http://www.whatever.com"
Dim myCred As New NetworkCredential("userid", "password", "domain")
Dim myURI As New Uri(strURI)
Dim myCache As New CredentialCache
myCache.Add(myURI, "Basic", myCred)

From this, I have attempted to use WebRequests and WebResponses to somehow
allow me to direct the browser to a different page, and use the credential I
have generated. The most I can do, however, is create the request and
receive the response:

Dim myWebRequest As System.Net.WebRequest =
System.Net.WebRequest.Create(strURI)
myWebRequest.Credentials = myCache
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()

If only I could use the response.redirect method, and somehow pass the
credentials with the redirection (like you can with the webrequest), it
could work!

I have also attempted to use the LogonUser API (from the advapi32.dll), and
impersonate a user based on the proper logon information -- this works, and
I'm able to successfully impersonate the user, but again, I don't know how
to pass along the user context to a different page.

I know that many people will say "just use form based authentication," but
this will not work for me, as I want this to work with tools like Outlook
Web Access, which requires windows authentication.

Any help would be greatly appreciated. Thank you!!

Wadewhile your only option is to use redirect to
http://username:password@.somesite.com (if using basic), I wouldn't do that
either.

anything else -- can't do.

"Wade Wegner" <wwegner23@.hotmail.com> wrote in message
news:OULm1aKzDHA.2116@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I have been desperately trying to programmatically authenticate a windows
> user, create their credentials, and then redirect them to a different
server
> while passing the credentials at the same time so that they don't have to
> login again.
> Specifically, I have two webservers in the same domain. When I have a
user
> go to Webserver A (which uses basic authentication) I programmatically
> create either a user credential or impersonate a user context (for now
it's
> hardcoded, but in the future it would be entered in forms). Then, I want
to
> let that user access a page on Webserver B (which uses basic
> authentication), but I don't want them to have to login again -- rather, I
> want to use the user context that I programmatically created on Webserver
A.
> For instance, here is an example of the code I use to create the user
> credentials:
> Dim strURI = "http://www.whatever.com"
> Dim myCred As New NetworkCredential("userid", "password", "domain")
> Dim myURI As New Uri(strURI)
> Dim myCache As New CredentialCache
> myCache.Add(myURI, "Basic", myCred)
> From this, I have attempted to use WebRequests and WebResponses to somehow
> allow me to direct the browser to a different page, and use the credential
I
> have generated. The most I can do, however, is create the request and
> receive the response:
> Dim myWebRequest As System.Net.WebRequest =
> System.Net.WebRequest.Create(strURI)
> myWebRequest.Credentials = myCache
> Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
> If only I could use the response.redirect method, and somehow pass the
> credentials with the redirection (like you can with the webrequest), it
> could work!
> I have also attempted to use the LogonUser API (from the advapi32.dll),
and
> impersonate a user based on the proper logon information -- this works,
and
> I'm able to successfully impersonate the user, but again, I don't know how
> to pass along the user context to a different page.
> I know that many people will say "just use form based authentication,"
but
> this will not work for me, as I want this to work with tools like Outlook
> Web Access, which requires windows authentication.
> Any help would be greatly appreciated. Thank you!!
> Wade
if they are your own servers, you could set up a webservice to transfer
session info back and forth...

"Wade Wegner" <wwegner23@.hotmail.com> wrote in message
news:OULm1aKzDHA.2116@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I have been desperately trying to programmatically authenticate a windows
> user, create their credentials, and then redirect them to a different
server
> while passing the credentials at the same time so that they don't have to
> login again.
> Specifically, I have two webservers in the same domain. When I have a
user
> go to Webserver A (which uses basic authentication) I programmatically
> create either a user credential or impersonate a user context (for now
it's
> hardcoded, but in the future it would be entered in forms). Then, I want
to
> let that user access a page on Webserver B (which uses basic
> authentication), but I don't want them to have to login again -- rather, I
> want to use the user context that I programmatically created on Webserver
A.
> For instance, here is an example of the code I use to create the user
> credentials:
> Dim strURI = "http://www.whatever.com"
> Dim myCred As New NetworkCredential("userid", "password", "domain")
> Dim myURI As New Uri(strURI)
> Dim myCache As New CredentialCache
> myCache.Add(myURI, "Basic", myCred)
> From this, I have attempted to use WebRequests and WebResponses to somehow
> allow me to direct the browser to a different page, and use the credential
I
> have generated. The most I can do, however, is create the request and
> receive the response:
> Dim myWebRequest As System.Net.WebRequest =
> System.Net.WebRequest.Create(strURI)
> myWebRequest.Credentials = myCache
> Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
> If only I could use the response.redirect method, and somehow pass the
> credentials with the redirection (like you can with the webrequest), it
> could work!
> I have also attempted to use the LogonUser API (from the advapi32.dll),
and
> impersonate a user based on the proper logon information -- this works,
and
> I'm able to successfully impersonate the user, but again, I don't know how
> to pass along the user context to a different page.
> I know that many people will say "just use form based authentication,"
but
> this will not work for me, as I want this to work with tools like Outlook
> Web Access, which requires windows authentication.
> Any help would be greatly appreciated. Thank you!!
> Wade
Huh!

I never you could do that to pass login information to a site with basic
authentication. Is there a name for that? Something that would allow me to
look it up in MSDN? I wonder what the security considerations are. If used
with SSL, is it safe? Etc.

Thanks for the idea, though ... I'll look into it some more.

Wade

"Rad" <aspdotnet@.hot.spam.mail.com> wrote in message
news:hjkHb.212029$I53.8627510@.twister.southeast.rr .com...
> while your only option is to use redirect to
> http://username:password@.somesite.com (if using basic), I wouldn't do that
> either.
> anything else -- can't do.
>
> "Wade Wegner" <wwegner23@.hotmail.com> wrote in message
> news:OULm1aKzDHA.2116@.TK2MSFTNGP10.phx.gbl...
> > Hello,
> > I have been desperately trying to programmatically authenticate a
windows
> > user, create their credentials, and then redirect them to a different
> server
> > while passing the credentials at the same time so that they don't have
to
> > login again.
> > Specifically, I have two webservers in the same domain. When I have a
> user
> > go to Webserver A (which uses basic authentication) I programmatically
> > create either a user credential or impersonate a user context (for now
> it's
> > hardcoded, but in the future it would be entered in forms). Then, I
want
> to
> > let that user access a page on Webserver B (which uses basic
> > authentication), but I don't want them to have to login again -- rather,
I
> > want to use the user context that I programmatically created on
Webserver
> A.
> > For instance, here is an example of the code I use to create the user
> > credentials:
> > Dim strURI = "http://www.whatever.com"
> > Dim myCred As New NetworkCredential("userid", "password", "domain")
> > Dim myURI As New Uri(strURI)
> > Dim myCache As New CredentialCache
> > myCache.Add(myURI, "Basic", myCred)
> > From this, I have attempted to use WebRequests and WebResponses to
somehow
> > allow me to direct the browser to a different page, and use the
credential
> I
> > have generated. The most I can do, however, is create the request and
> > receive the response:
> > Dim myWebRequest As System.Net.WebRequest =
> > System.Net.WebRequest.Create(strURI)
> > myWebRequest.Credentials = myCache
> > Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
> > If only I could use the response.redirect method, and somehow pass the
> > credentials with the redirection (like you can with the webrequest), it
> > could work!
> > I have also attempted to use the LogonUser API (from the advapi32.dll),
> and
> > impersonate a user based on the proper logon information -- this works,
> and
> > I'm able to successfully impersonate the user, but again, I don't know
how
> > to pass along the user context to a different page.
> > I know that many people will say "just use form based authentication,"
> but
> > this will not work for me, as I want this to work with tools like
Outlook
> > Web Access, which requires windows authentication.
> > Any help would be greatly appreciated. Thank you!!
> > Wade
Okay, as I've been playing with the method you mentioned, I've noted the
following.

If I create a login form, and then programmatically create a URL string, and
then redirect to that URL, it prompts me to login. However, if I register a
vbscript that uses window.location to redirect the user to this script, it
doesn't. Does the response.redirect not work?

For example, this is what I use for the response.redirect:

Dim strURL as string
strURL = "http://" & txtUserID.Text & ":" & txtPassword.Text &
"@.mydomain.com"

response.redirect(strURL)

That doesn't work, and it prompts me to login.

However, I can get the following to work fine:

Dim strURL as string
strURL = "http://" & txtUserID.Text & ":" & txtPassword.Text &
"@.mydomain.com"

Dim txtScript as new System.Text.StringBuilder
txtScript.Append(vbCr & "<script language=vbscript>")
txtScript.Append(vbCr & "window.location = """ & strURL & """")
txtScript.Append(vbCr & "</script>" & vbCr & vbCr)

Page.RegisterStartupScript("redirect", txtScript.ToString)

When I redirect from the client, this works fine. Additionally, if I simply
type in the address into the browser, it works properly.

Any ideas? Will I have to do this from the client?

Thanks,

Wade

"Rad" <aspdotnet@.hot.spam.mail.com> wrote in message
news:hjkHb.212029$I53.8627510@.twister.southeast.rr .com...
> while your only option is to use redirect to
> http://username:password@.somesite.com (if using basic), I wouldn't do that
> either.
> anything else -- can't do.
>
> "Wade Wegner" <wwegner23@.hotmail.com> wrote in message
> news:OULm1aKzDHA.2116@.TK2MSFTNGP10.phx.gbl...
> > Hello,
> > I have been desperately trying to programmatically authenticate a
windows
> > user, create their credentials, and then redirect them to a different
> server
> > while passing the credentials at the same time so that they don't have
to
> > login again.
> > Specifically, I have two webservers in the same domain. When I have a
> user
> > go to Webserver A (which uses basic authentication) I programmatically
> > create either a user credential or impersonate a user context (for now
> it's
> > hardcoded, but in the future it would be entered in forms). Then, I
want
> to
> > let that user access a page on Webserver B (which uses basic
> > authentication), but I don't want them to have to login again -- rather,
I
> > want to use the user context that I programmatically created on
Webserver
> A.
> > For instance, here is an example of the code I use to create the user
> > credentials:
> > Dim strURI = "http://www.whatever.com"
> > Dim myCred As New NetworkCredential("userid", "password", "domain")
> > Dim myURI As New Uri(strURI)
> > Dim myCache As New CredentialCache
> > myCache.Add(myURI, "Basic", myCred)
> > From this, I have attempted to use WebRequests and WebResponses to
somehow
> > allow me to direct the browser to a different page, and use the
credential
> I
> > have generated. The most I can do, however, is create the request and
> > receive the response:
> > Dim myWebRequest As System.Net.WebRequest =
> > System.Net.WebRequest.Create(strURI)
> > myWebRequest.Credentials = myCache
> > Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
> > If only I could use the response.redirect method, and somehow pass the
> > credentials with the redirection (like you can with the webrequest), it
> > could work!
> > I have also attempted to use the LogonUser API (from the advapi32.dll),
> and
> > impersonate a user based on the proper logon information -- this works,
> and
> > I'm able to successfully impersonate the user, but again, I don't know
how
> > to pass along the user context to a different page.
> > I know that many people will say "just use form based authentication,"
> but
> > this will not work for me, as I want this to work with tools like
Outlook
> > Web Access, which requires windows authentication.
> > Any help would be greatly appreciated. Thank you!!
> > Wade
I don't like this approach (of passing credentials like this) at all.. it's
visible in the address bar.. so I'm not sure this is really a good idea.

it's an HTTP thingie.. so you would want to look at it there.. MSDN may have
it.. but may not...

"Wade Wegner" <wwegner23@.hotmail.com> wrote in message
news:uUmNq0hzDHA.1744@.TK2MSFTNGP12.phx.gbl...
> Okay, as I've been playing with the method you mentioned, I've noted the
> following.
> If I create a login form, and then programmatically create a URL string,
and
> then redirect to that URL, it prompts me to login. However, if I register
a
> vbscript that uses window.location to redirect the user to this script, it
> doesn't. Does the response.redirect not work?
> For example, this is what I use for the response.redirect:
> Dim strURL as string
> strURL = "http://" & txtUserID.Text & ":" & txtPassword.Text &
> "@.mydomain.com"
> response.redirect(strURL)
> That doesn't work, and it prompts me to login.
> However, I can get the following to work fine:
> Dim strURL as string
> strURL = "http://" & txtUserID.Text & ":" & txtPassword.Text &
> "@.mydomain.com"
> Dim txtScript as new System.Text.StringBuilder
> txtScript.Append(vbCr & "<script language=vbscript>")
> txtScript.Append(vbCr & "window.location = """ & strURL & """")
> txtScript.Append(vbCr & "</script>" & vbCr & vbCr)
> Page.RegisterStartupScript("redirect", txtScript.ToString)
> When I redirect from the client, this works fine. Additionally, if I
simply
> type in the address into the browser, it works properly.
> Any ideas? Will I have to do this from the client?
> Thanks,
> Wade
>
> "Rad" <aspdotnet@.hot.spam.mail.com> wrote in message
> news:hjkHb.212029$I53.8627510@.twister.southeast.rr .com...
> > while your only option is to use redirect to
> > http://username:password@.somesite.com (if using basic), I wouldn't do
that
> > either.
> > anything else -- can't do.
> > "Wade Wegner" <wwegner23@.hotmail.com> wrote in message
> > news:OULm1aKzDHA.2116@.TK2MSFTNGP10.phx.gbl...
> > > Hello,
> > > > I have been desperately trying to programmatically authenticate a
> windows
> > > user, create their credentials, and then redirect them to a different
> > server
> > > while passing the credentials at the same time so that they don't have
> to
> > > login again.
> > > > Specifically, I have two webservers in the same domain. When I have a
> > user
> > > go to Webserver A (which uses basic authentication) I programmatically
> > > create either a user credential or impersonate a user context (for now
> > it's
> > > hardcoded, but in the future it would be entered in forms). Then, I
> want
> > to
> > > let that user access a page on Webserver B (which uses basic
> > > authentication), but I don't want them to have to login again --
rather,
> I
> > > want to use the user context that I programmatically created on
> Webserver
> > A.
> > > > For instance, here is an example of the code I use to create the user
> > > credentials:
> > > > Dim strURI = "http://www.whatever.com"
> > > Dim myCred As New NetworkCredential("userid", "password",
"domain")
> > > Dim myURI As New Uri(strURI)
> > > Dim myCache As New CredentialCache
> > > myCache.Add(myURI, "Basic", myCred)
> > > > From this, I have attempted to use WebRequests and WebResponses to
> somehow
> > > allow me to direct the browser to a different page, and use the
> credential
> > I
> > > have generated. The most I can do, however, is create the request and
> > > receive the response:
> > > > Dim myWebRequest As System.Net.WebRequest =
> > > System.Net.WebRequest.Create(strURI)
> > > myWebRequest.Credentials = myCache
> > > Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
> > > > If only I could use the response.redirect method, and somehow pass the
> > > credentials with the redirection (like you can with the webrequest),
it
> > > could work!
> > > > I have also attempted to use the LogonUser API (from the
advapi32.dll),
> > and
> > > impersonate a user based on the proper logon information -- this
works,
> > and
> > > I'm able to successfully impersonate the user, but again, I don't know
> how
> > > to pass along the user context to a different page.
> > > > I know that many people will say "just use form based authentication,"
> > but
> > > this will not work for me, as I want this to work with tools like
> Outlook
> > > Web Access, which requires windows authentication.
> > > > Any help would be greatly appreciated. Thank you!!
> > > > Wade
> >
See, I do not experience it displaying in the address bar. I have not been
able to find anything in MSDN concerning this, but I started to think that
all this method does is mimic what basic authentication does -- I mean,
basic authentication is unencrypted, clear text. Is employing this method
any different than using basic authentication? In both cases, obviously, it
would be worthwhile to encrypt using SSL.

I still wish I understood why this solution would not work if redirected
from the server, via response.redirect, but will if it is redirected at the
client. Even if this isn't a good solution, I'd like to know the answer to
that.

"Rad" <aspdotnet@.hot.spam.mail.com> wrote in message
news:or3Ib.161313$Vu5.11592556@.twister.southeast.r r.com...
> I don't like this approach (of passing credentials like this) at all..
it's
> visible in the address bar.. so I'm not sure this is really a good idea.
> it's an HTTP thingie.. so you would want to look at it there.. MSDN may
have
> it.. but may not...
> "Wade Wegner" <wwegner23@.hotmail.com> wrote in message
> news:uUmNq0hzDHA.1744@.TK2MSFTNGP12.phx.gbl...
> > Okay, as I've been playing with the method you mentioned, I've noted the
> > following.
> > If I create a login form, and then programmatically create a URL string,
> and
> > then redirect to that URL, it prompts me to login. However, if I
register
> a
> > vbscript that uses window.location to redirect the user to this script,
it
> > doesn't. Does the response.redirect not work?
> > For example, this is what I use for the response.redirect:
> > Dim strURL as string
> > strURL = "http://" & txtUserID.Text & ":" & txtPassword.Text &
> > "@.mydomain.com"
> > response.redirect(strURL)
> > That doesn't work, and it prompts me to login.
> > However, I can get the following to work fine:
> > Dim strURL as string
> > strURL = "http://" & txtUserID.Text & ":" & txtPassword.Text &
> > "@.mydomain.com"
> > Dim txtScript as new System.Text.StringBuilder
> > txtScript.Append(vbCr & "<script language=vbscript>")
> > txtScript.Append(vbCr & "window.location = """ & strURL & """")
> > txtScript.Append(vbCr & "</script>" & vbCr & vbCr)
> > Page.RegisterStartupScript("redirect", txtScript.ToString)
> > When I redirect from the client, this works fine. Additionally, if I
> simply
> > type in the address into the browser, it works properly.
> > Any ideas? Will I have to do this from the client?
> > Thanks,
> > Wade
> > "Rad" <aspdotnet@.hot.spam.mail.com> wrote in message
> > news:hjkHb.212029$I53.8627510@.twister.southeast.rr .com...
> > > while your only option is to use redirect to
> > > http://username:password@.somesite.com (if using basic), I wouldn't do
> that
> > > either.
> > > > anything else -- can't do.
> > > > > "Wade Wegner" <wwegner23@.hotmail.com> wrote in message
> > > news:OULm1aKzDHA.2116@.TK2MSFTNGP10.phx.gbl...
> > > > Hello,
> > > > > > I have been desperately trying to programmatically authenticate a
> > windows
> > > > user, create their credentials, and then redirect them to a
different
> > > server
> > > > while passing the credentials at the same time so that they don't
have
> > to
> > > > login again.
> > > > > > Specifically, I have two webservers in the same domain. When I have
a
> > > user
> > > > go to Webserver A (which uses basic authentication) I
programmatically
> > > > create either a user credential or impersonate a user context (for
now
> > > it's
> > > > hardcoded, but in the future it would be entered in forms). Then, I
> > want
> > > to
> > > > let that user access a page on Webserver B (which uses basic
> > > > authentication), but I don't want them to have to login again --
> rather,
> > I
> > > > want to use the user context that I programmatically created on
> > Webserver
> > > A.
> > > > > > For instance, here is an example of the code I use to create the
user
> > > > credentials:
> > > > > > Dim strURI = "http://www.whatever.com"
> > > > Dim myCred As New NetworkCredential("userid", "password",
> "domain")
> > > > Dim myURI As New Uri(strURI)
> > > > Dim myCache As New CredentialCache
> > > > myCache.Add(myURI, "Basic", myCred)
> > > > > > From this, I have attempted to use WebRequests and WebResponses to
> > somehow
> > > > allow me to direct the browser to a different page, and use the
> > credential
> > > I
> > > > have generated. The most I can do, however, is create the request
and
> > > > receive the response:
> > > > > > Dim myWebRequest As System.Net.WebRequest =
> > > > System.Net.WebRequest.Create(strURI)
> > > > myWebRequest.Credentials = myCache
> > > > Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
> > > > > > If only I could use the response.redirect method, and somehow pass
the
> > > > credentials with the redirection (like you can with the webrequest),
> it
> > > > could work!
> > > > > > I have also attempted to use the LogonUser API (from the
> advapi32.dll),
> > > and
> > > > impersonate a user based on the proper logon information -- this
> works,
> > > and
> > > > I'm able to successfully impersonate the user, but again, I don't
know
> > how
> > > > to pass along the user context to a different page.
> > > > > > I know that many people will say "just use form based
authentication,"
> > > but
> > > > this will not work for me, as I want this to work with tools like
> > Outlook
> > > > Web Access, which requires windows authentication.
> > > > > > Any help would be greatly appreciated. Thank you!!
> > > > > > Wade
> > > > > >
Look at HTTP specs... see what it says for 302 (that's what
response.redirect really is)...

as I said, all this is http stuff.. so MSDN may not have it (just like they
dont' have http specs there...) you'd probably want to start looking at
w3c's site

"Wade Wegner" <wwegner23@.hotmail.com> wrote in message
news:%233lbcWuzDHA.2160@.TK2MSFTNGP12.phx.gbl...
> See, I do not experience it displaying in the address bar. I have not
been
> able to find anything in MSDN concerning this, but I started to think that
> all this method does is mimic what basic authentication does -- I mean,
> basic authentication is unencrypted, clear text. Is employing this method
> any different than using basic authentication? In both cases, obviously,
it
> would be worthwhile to encrypt using SSL.
> I still wish I understood why this solution would not work if redirected
> from the server, via response.redirect, but will if it is redirected at
the
> client. Even if this isn't a good solution, I'd like to know the answer
to
> that.
>
> "Rad" <aspdotnet@.hot.spam.mail.com> wrote in message
> news:or3Ib.161313$Vu5.11592556@.twister.southeast.r r.com...
> > I don't like this approach (of passing credentials like this) at all..
> it's
> > visible in the address bar.. so I'm not sure this is really a good idea.
> > it's an HTTP thingie.. so you would want to look at it there.. MSDN may
> have
> > it.. but may not...
> > "Wade Wegner" <wwegner23@.hotmail.com> wrote in message
> > news:uUmNq0hzDHA.1744@.TK2MSFTNGP12.phx.gbl...
> > > Okay, as I've been playing with the method you mentioned, I've noted
the
> > > following.
> > > > If I create a login form, and then programmatically create a URL
string,
> > and
> > > then redirect to that URL, it prompts me to login. However, if I
> register
> > a
> > > vbscript that uses window.location to redirect the user to this
script,
> it
> > > doesn't. Does the response.redirect not work?
> > > > For example, this is what I use for the response.redirect:
> > > > Dim strURL as string
> > > strURL = "http://" & txtUserID.Text & ":" & txtPassword.Text &
> > > "@.mydomain.com"
> > > > response.redirect(strURL)
> > > > That doesn't work, and it prompts me to login.
> > > > However, I can get the following to work fine:
> > > > Dim strURL as string
> > > strURL = "http://" & txtUserID.Text & ":" & txtPassword.Text &
> > > "@.mydomain.com"
> > > > Dim txtScript as new System.Text.StringBuilder
> > > txtScript.Append(vbCr & "<script language=vbscript>")
> > > txtScript.Append(vbCr & "window.location = """ & strURL & """")
> > > txtScript.Append(vbCr & "</script>" & vbCr & vbCr)
> > > > Page.RegisterStartupScript("redirect", txtScript.ToString)
> > > > When I redirect from the client, this works fine. Additionally, if I
> > simply
> > > type in the address into the browser, it works properly.
> > > > Any ideas? Will I have to do this from the client?
> > > > Thanks,
> > > > Wade
> > > > > > "Rad" <aspdotnet@.hot.spam.mail.com> wrote in message
> > > news:hjkHb.212029$I53.8627510@.twister.southeast.rr .com...
> > > > while your only option is to use redirect to
> > > > http://username:password@.somesite.com (if using basic), I wouldn't
do
> > that
> > > > either.
> > > > > > anything else -- can't do.
> > > > > > > > "Wade Wegner" <wwegner23@.hotmail.com> wrote in message
> > > > news:OULm1aKzDHA.2116@.TK2MSFTNGP10.phx.gbl...
> > > > > Hello,
> > > > > > > > I have been desperately trying to programmatically authenticate a
> > > windows
> > > > > user, create their credentials, and then redirect them to a
> different
> > > > server
> > > > > while passing the credentials at the same time so that they don't
> have
> > > to
> > > > > login again.
> > > > > > > > Specifically, I have two webservers in the same domain. When I
have
> a
> > > > user
> > > > > go to Webserver A (which uses basic authentication) I
> programmatically
> > > > > create either a user credential or impersonate a user context (for
> now
> > > > it's
> > > > > hardcoded, but in the future it would be entered in forms). Then,
I
> > > want
> > > > to
> > > > > let that user access a page on Webserver B (which uses basic
> > > > > authentication), but I don't want them to have to login again --
> > rather,
> > > I
> > > > > want to use the user context that I programmatically created on
> > > Webserver
> > > > A.
> > > > > > > > For instance, here is an example of the code I use to create the
> user
> > > > > credentials:
> > > > > > > > Dim strURI = "http://www.whatever.com"
> > > > > Dim myCred As New NetworkCredential("userid", "password",
> > "domain")
> > > > > Dim myURI As New Uri(strURI)
> > > > > Dim myCache As New CredentialCache
> > > > > myCache.Add(myURI, "Basic", myCred)
> > > > > > > > From this, I have attempted to use WebRequests and WebResponses to
> > > somehow
> > > > > allow me to direct the browser to a different page, and use the
> > > credential
> > > > I
> > > > > have generated. The most I can do, however, is create the request
> and
> > > > > receive the response:
> > > > > > > > Dim myWebRequest As System.Net.WebRequest =
> > > > > System.Net.WebRequest.Create(strURI)
> > > > > myWebRequest.Credentials = myCache
> > > > > Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
> > > > > > > > If only I could use the response.redirect method, and somehow pass
> the
> > > > > credentials with the redirection (like you can with the
webrequest),
> > it
> > > > > could work!
> > > > > > > > I have also attempted to use the LogonUser API (from the
> > advapi32.dll),
> > > > and
> > > > > impersonate a user based on the proper logon information -- this
> > works,
> > > > and
> > > > > I'm able to successfully impersonate the user, but again, I don't
> know
> > > how
> > > > > to pass along the user context to a different page.
> > > > > > > > I know that many people will say "just use form based
> authentication,"
> > > > but
> > > > > this will not work for me, as I want this to work with tools like
> > > Outlook
> > > > > Web Access, which requires windows authentication.
> > > > > > > > Any help would be greatly appreciated. Thank you!!
> > > > > > > > Wade
> > > > > > > > > > > >

Friday, March 16, 2012

password fields

why is it that password fields:

<asp:TextBox Id="txtuserpassword1" TextMode="password" class="textbox" maxlength="20" Columns="15" Runat="Server" /><br
clear everytime validation kicks in or on page refreshes? Can this be stopped? Help!
Also, I can't auto-populate the password field uising a database value.

Help. Thanx.This is the default behavior. If password fields were to refresh, they would have to be stored in ViewState. Since ViewState is stored on the HTML rendered to the browser, the user can easily do a view source and have access to the password. This defeats the purpose of having the password masked.

There is no way to override this, unless you make a custom control, or some other work around.

hope this helps,
John

"Chris" wrote:

> why is it that password fields:
> <asp:TextBox Id="txtuserpassword1" TextMode="password" class="textbox" maxlength="20" Columns="15" Runat="Server" /><br>
> clear everytime validation kicks in or on page refreshes? Can this be stopped? Help!
> Also, I can't auto-populate the password field uising a database value.
> Help. Thanx.
ok, I can buy the "refresh" reason but what about setting to a value via a database call:

txtuserpassword1.Text = "" & memberdata("USER_PASSWORD")
txtuserpassword2.Text = "" & memberdata("USER_PASSWORD")

they won't populate, why?
thanx.

"John Sivilla" wrote:

> This is the default behavior. If password fields were to refresh, they would have to be stored in ViewState. Since ViewState is stored on the HTML rendered to the browser, the user can easily do a view source and have access to the password. This defeats the purpose of having the password masked.
> There is no way to override this, unless you make a custom control, or some other work around.
> hope this helps,
> John
> "Chris" wrote:
> > why is it that password fields:
> > <asp:TextBox Id="txtuserpassword1" TextMode="password" class="textbox" maxlength="20" Columns="15" Runat="Server" /><br>
> > clear everytime validation kicks in or on page refreshes? Can this be stopped? Help!
> > Also, I can't auto-populate the password field uising a database value.
> > Help. Thanx.
My guess is it's built into the design of the server control. It would
seem to be a security risk to allow prepopulating a password field.
Perhaps you could do a JavaScript kludge to work around it though if you
really had to.

Chris wrote:

>why is it that password fields:
><asp:TextBox Id="txtuserpassword1" TextMode="password" class="textbox" maxlength="20" Columns="15" Runat="Server" /><br>
>clear everytime validation kicks in or on page refreshes? Can this be stopped? Help!
>Also, I can't auto-populate the password field uising a database value.
>Help. Thanx.
asp.net clears password fields by default. to set the values in code behind
use the value attribute:

txtuserpassword1.Attributes.Add("value",myPassedValue);

-- bruce (sqlwork.com)

"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:53BA7FBD-26A4-458A-BA32-0AB61190C1E6@.microsoft.com...
> why is it that password fields:
> <asp:TextBox Id="txtuserpassword1" TextMode="password" class="textbox"
maxlength="20" Columns="15" Runat="Server" /><br>
> clear everytime validation kicks in or on page refreshes? Can this be
stopped? Help!
> Also, I can't auto-populate the password field uising a database value.
> Help. Thanx.
This will work, but for security reasons, I would recommend not putting the
actual password value in there (as it can then become visible to the user if
they view source). Rather, I've often put in "********" as the value to
represent that something has been entered. The next time the user posts, if
that value matches, then I know they left it alone and the code responds
accordingly. Otherwise, they've made a change.

Ben Lucas
Lead Developer
Solien Technology, Inc.

"bruce barker" <nospam_brubar@.safeco.com> wrote in message
news:OOApwjbbEHA.368@.TK2MSFTNGP10.phx.gbl...
> asp.net clears password fields by default. to set the values in code
behind
> use the value attribute:
> txtuserpassword1.Attributes.Add("value",myPassedValue);
> -- bruce (sqlwork.com)
> "Chris" <Chris@.discussions.microsoft.com> wrote in message
> news:53BA7FBD-26A4-458A-BA32-0AB61190C1E6@.microsoft.com...
> > why is it that password fields:
> > <asp:TextBox Id="txtuserpassword1" TextMode="password" class="textbox"
> maxlength="20" Columns="15" Runat="Server" /><br>
> > clear everytime validation kicks in or on page refreshes? Can this be
> stopped? Help!
> > Also, I can't auto-populate the password field uising a database value.
> > Help. Thanx.

password fields

why is it that password fields:
<asp:TextBox Id="txtuserpassword1" TextMode="password" class="textbox" maxle
ngth="20" Columns="15" Runat="Server" /><br>
clear everytime validation kicks in or on page refreshes? Can this be stoppe
d? Help!
Also, I can't auto-populate the password field uising a database value.
Help. Thanx.This is the default behavior. If password fields were to refresh, they would
have to be stored in ViewState. Since ViewState is stored on the HTML rende
red to the browser, the user can easily do a view source and have access to
the password. This defeats
the purpose of having the password masked.
There is no way to override this, unless you make a custom control, or some
other work around.
hope this helps,
John
"Chris" wrote:

> why is it that password fields:
> <asp:TextBox Id="txtuserpassword1" TextMode="password" class="textbox" max
length="20" Columns="15" Runat="Server" /><br>
> clear everytime validation kicks in or on page refreshes? Can this be stop
ped? Help!
> Also, I can't auto-populate the password field uising a database value.
> Help. Thanx.
>
ok, I can buy the "refresh" reason but what about setting to a value via a d
atabase call:
txtuserpassword1.Text = "" & memberdata("USER_PASSWORD")
txtuserpassword2.Text = "" & memberdata("USER_PASSWORD")
they won't populate, why?
thanx.
"John Sivilla" wrote:

> This is the default behavior. If password fields were to refresh, they would have
to be stored in ViewState. Since ViewState is stored on the HTML rendered to the bro
wser, the user can easily do a view source and have access to the password. This def
eat
s the purpose of having the password masked.
> There is no way to override this, unless you make a custom control, or som
e other work around.
> hope this helps,
> John
> "Chris" wrote:
>
My guess is it's built into the design of the server control. It would
seem to be a security risk to allow prepopulating a password field.
Perhaps you could do a JavaScript kludge to work around it though if you
really had to.
Chris wrote:

>why is it that password fields:
><asp:TextBox Id="txtuserpassword1" TextMode="password" class="textbox" maxl
ength="20" Columns="15" Runat="Server" /><br>
>clear everytime validation kicks in or on page refreshes? Can this be stopp
ed? Help!
>Also, I can't auto-populate the password field uising a database value.
>Help. Thanx.
>
>
asp.net clears password fields by default. to set the values in code behind
use the value attribute:
txtuserpassword1.Attributes.Add("value",myPassedValue);
-- bruce (sqlwork.com)
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:53BA7FBD-26A4-458A-BA32-0AB61190C1E6@.microsoft.com...
> why is it that password fields:
> <asp:TextBox Id="txtuserpassword1" TextMode="password" class="textbox"
maxlength="20" Columns="15" Runat="Server" /><br>
> clear everytime validation kicks in or on page refreshes? Can this be
stopped? Help!
> Also, I can't auto-populate the password field uising a database value.
> Help. Thanx.
>
This will work, but for security reasons, I would recommend not putting the
actual password value in there (as it can then become visible to the user if
they view source). Rather, I've often put in "********" as the value to
represent that something has been entered. The next time the user posts, if
that value matches, then I know they left it alone and the code responds
accordingly. Otherwise, they've made a change.
Ben Lucas
Lead Developer
Solien Technology, Inc.
"bruce barker" <nospam_brubar@.safeco.com> wrote in message
news:OOApwjbbEHA.368@.TK2MSFTNGP10.phx.gbl...
> asp.net clears password fields by default. to set the values in code
behind
> use the value attribute:
> txtuserpassword1.Attributes.Add("value",myPassedValue);
> -- bruce (sqlwork.com)
> "Chris" <Chris@.discussions.microsoft.com> wrote in message
> news:53BA7FBD-26A4-458A-BA32-0AB61190C1E6@.microsoft.com...
> maxlength="20" Columns="15" Runat="Server" /><br>
> stopped? Help!
>
does the trick, thanx a lot!
"bruce barker" wrote:

> asp.net clears password fields by default. to set the values in code behin
d
> use the value attribute:
> txtuserpassword1.Attributes.Add("value",myPassedValue);
> -- bruce (sqlwork.com)
> "Chris" <Chris@.discussions.microsoft.com> wrote in message
> news:53BA7FBD-26A4-458A-BA32-0AB61190C1E6@.microsoft.com...
> maxlength="20" Columns="15" Runat="Server" /><br>
> stopped? Help!
>
>
good suggestions, I never thought of that!
"Ben Lucas" wrote:

> This will work, but for security reasons, I would recommend not putting th
e
> actual password value in there (as it can then become visible to the user
if
> they view source). Rather, I've often put in "********" as the value to
> represent that something has been entered. The next time the user posts,
if
> that value matches, then I know they left it alone and the code responds
> accordingly. Otherwise, they've made a change.
> Ben Lucas
> Lead Developer
> Solien Technology, Inc.
> "bruce barker" <nospam_brubar@.safeco.com> wrote in message
> news:OOApwjbbEHA.368@.TK2MSFTNGP10.phx.gbl...
> behind
>
>

Password goes blank. When I make round trip to server

I have a simple Data Entry form that User enters some information....One of these fields is a password field...Now i have a textBox and and the TextMode is set to Password...but I am unable to save the password to the database cause when i check a check box who's AutoPostBack is set to true the text in textbox with its text mode set to password just goes back to being blank when the page reloads....I dont understand why...I am using ASP.Net 1.1 VS 03 and Sql Backend......I just want to be able to save my Passwords to the DB so that the user will be able to log in and I can authenicate him..........

More then likely you are blanking it in the Page_Load()

Ensure you have a:
If Not IsPostBack() then
... clear password
End if


I thought that but when I change the text mode to Single line...it works just fine....

I've seen the same behavior. I believe this is a security feature. You can use the following approach to work around it.

PrivateSub Page_PreRender(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMyBase.PreRender

Password.Attributes.Add(

"value", Password.Text)

ConfirmPassword.Attributes.Add(

"value", ConfirmPassword.Text)EndSub

Password Input Boxes

Hey Guys,

How would I make a password box that shows the ********** ?

Something like this
<asp:PassBox id="NewPassword" runat="server" /
Just can't find the answer.

Thank you!Hi there,

The TextBox web control has a TextMode called "Password" that does this for you.

HTH,

Covo
You would do this.

<asp:textbox id="passwordfield" textmode="password" runat="server" /
Then it will show up as ****

Keep in mind, any time you want a user to type something in, you always use the asp:textbox. But the textbox has different 'texmode's. such as single line, multi line, or password. Does this help?