Showing posts with label aspnet. Show all posts
Showing posts with label aspnet. Show all posts

Monday, March 26, 2012

pass the web value from asp.net to asp by url

hi all,

i have two web files, one is *.aspx and the other is *.asp

i need pass textbox.text value from *.aspx to *.asp

so i can process the value(ex:string ) in *.asp

i pass the value like this

<a href="http://links.10026.com/?link=iflowall.asp?case_no=<%=(case.Text)%>&bank_no=<%=(bank_no.Text)%>">connect</a></p>

and receive from *.aspx like this

<td><%= Request.QueryString("case_no") %>於<%= Request.QueryString("bank_name") %></td>

in *.asp, it can't decode the string "bank_name" so the value is null why?

if the string is about number(ex:1234) it`s ok, but wrong when the string is chinses word(ex:中文)

Not a asp guru but you do not seem to have a query string parameter "bank_name" (only bank_no) when constructing the string in asp?
Yes you got the Query string wrong. As in your .aspx constructed url, the query string parameter is bank_no not bank_name

Pass UserID instead of Username to other pages after logged on, ASP.NET 2.0

Hi,
I have my own user table with definition like
UserID int not null primary key,
Username varchar(50) not null,
Password varchar(50) not null,
Firstname varchar(50) not null,
Lastname varchar(50) not null,
Email varchar(50) not null,
....
I create my own Membership provider to inherit SqlMembershipProvider
public class MyMembershipProvider :
System.Web.Security.SqlMembershipProvider {
public MyMembershipProvider() {
}
public override bool ValidateUser(string username, string password) {
// query my DB to verify user
MyUser mu = new MyUser();
return mu.VerifyUser(username, password);
}
}
In Asp.Net 1.1, we can use
FormsAuthentication.RedirectFromLoginPage(UserID.ToString(), false); to save
UserID (which is whatever I return from my own function, including UserID
from User table). Later on, we just call User.Identity.Name to retrieve the
UserID and it could be used as I like.
But in ASP.NET 2.0, I just need to add
<membership defaultProvider="MyMembershipProvider">
<providers>
<add name="MyMembershipProvider"
type="MyMembershipProvider"/>
</providers>
</membership>
to my web.config file, it will handle authentication autimatically. In this
case how can I pass UserID instead of username to other pages?
Thanks
HardyHardy,
Why pass it around? Why not set a session variable with the information
you need?
- Nicholas Paldino [.NET/C# MVP]
- mvp@.spam.guard.caspershouse.com
"Hardy Wang" <hardywang@.hotmail.com> wrote in message
news:umAPpLP%23FHA.1988@.TK2MSFTNGP12.phx.gbl...
> Hi,
> I have my own user table with definition like
> UserID int not null primary key,
> Username varchar(50) not null,
> Password varchar(50) not null,
> Firstname varchar(50) not null,
> Lastname varchar(50) not null,
> Email varchar(50) not null,
> ....
> I create my own Membership provider to inherit SqlMembershipProvider
> public class MyMembershipProvider :
> System.Web.Security.SqlMembershipProvider {
> public MyMembershipProvider() {
> }
> public override bool ValidateUser(string username, string password) {
> // query my DB to verify user
> MyUser mu = new MyUser();
> return mu.VerifyUser(username, password);
> }
> }
> In Asp.Net 1.1, we can use
> FormsAuthentication.RedirectFromLoginPage(UserID.ToString(), false); to
> save UserID (which is whatever I return from my own function, including
> UserID from User table). Later on, we just call User.Identity.Name to
> retrieve the UserID and it could be used as I like.
> But in ASP.NET 2.0, I just need to add
> <membership defaultProvider="MyMembershipProvider">
> <providers>
> <add name="MyMembershipProvider"
> type="MyMembershipProvider"/>
> </providers>
> </membership>
> to my web.config file, it will handle authentication autimatically. In
> this case how can I pass UserID instead of username to other pages?
>
> Thanks
> Hardy
>

Pass values between 2 asp.net applications

I have two asp.net web applications.
The 1st appn has a login page and the other appln has other pages.
When the user logs from 1st appln, i want to pass the username to be passed to the other application.
I do not want to pass through query string.
Is there other way out. Please help!!!!!!!!!

SaifIs there a reason why they are in seperate apps?

However, to solve the problem you could try using a Cookie.

Saturday, March 24, 2012

Pass viewstate to a new window in asp.net 2.0

I want to pop open a new window from my asp.net 2.0 web page. I want it to
pass or submit the current viewstate to the new window. Does anyone know ho
w
to do that? Thanks.Hi,
by using cross-page posting (PostBackUrl on buttons etc) and changing form's
target to be a new window, that's quite near . Following from my previous
post to this group
"
Hi,
one way is to change form's target when posting
<asp:Button ID="Button1" OnClientClick="form1.target='_blank'"
runat="server" Text="Button" PostBackUrl="~/Default2.aspx" />
You just might also turn it back after posting, in case other buttons still
continue posting on the same page.
"
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"lanem" <lanem@.discussions.microsoft.com> wrote in message
news:B6335CAE-75AD-4D9D-9C3A-E0962A457FDF@.microsoft.com...
>I want to pop open a new window from my asp.net 2.0 web page. I want it to
> pass or submit the current viewstate to the new window. Does anyone know
> how
> to do that? Thanks.
Hi lanem,
If you want to pass data to other pages, it's better to use Session, Cookie
rather than ViewState. ViewSate stores data in page hidden field, can not be
retrieved in other pages.
HTH
Elton Wang
"lanem" wrote:

> I want to pop open a new window from my asp.net 2.0 web page. I want it t
o
> pass or submit the current viewstate to the new window. Does anyone know
how
> to do that? Thanks.

Pass viewstate to a new window in asp.net 2.0

I want to pop open a new window from my asp.net 2.0 web page. I want it to
pass or submit the current viewstate to the new window. Does anyone know how
to do that? Thanks.Hi,

by using cross-page posting (PostBackUrl on buttons etc) and changing form's
target to be a new window, that's quite near . Following from my previous
post to this group

"
Hi,

one way is to change form's target when posting

<asp:Button ID="Button1" OnClientClick="form1.target='_blank'"
runat="server" Text="Button" PostBackUrl="~/Default2.aspx" /
You just might also turn it back after posting, in case other buttons still
continue posting on the same page.
"

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

"lanem" <lanem@.discussions.microsoft.com> wrote in message
news:B6335CAE-75AD-4D9D-9C3A-E0962A457FDF@.microsoft.com...
>I want to pop open a new window from my asp.net 2.0 web page. I want it to
> pass or submit the current viewstate to the new window. Does anyone know
> how
> to do that? Thanks.
Hi lanem,

If you want to pass data to other pages, it's better to use Session, Cookie
rather than ViewState. ViewSate stores data in page hidden field, can not be
retrieved in other pages.

HTH

Elton Wang

"lanem" wrote:

> I want to pop open a new window from my asp.net 2.0 web page. I want it to
> pass or submit the current viewstate to the new window. Does anyone know how
> to do that? Thanks.

Wednesday, March 21, 2012

Passing a UserControl as a parameter in ASP.NET 2

I have a few user controls which I would like to pass to a function which is not on the page the usercontrols have been placed in.

The function is in the App_Code directory so I can access it from anywhere in the project but I can't refer to the user control in the parameters of the function, therefore I can't access the usercontrol.

I'm not allowed to place the UserControl in the App_Code directory, so how can I create an instance of it?

Do you have control of the server where the app is going to be deployed ?

ie is it for an in house development or are you going to upload it to a public server ?

i ask coz if you have control of the server one way around the problem is to

make a dll (class) and by putting the code in the class your program will be able to access the code

Mark
Thanks Mark, will do that by building a dll. Only thing is I'm surprised that there is no way to do this using the ASP.NET 2 development model - the App_Code directory was supposed to replace the procedure of building and referencing dll's.

Friday, March 16, 2012

Passing a variable value from Javascript to asp.net server variable

Hi all,

I am using javascript confirm() function to get user's confirmation
from codebehind after a condition is met. I don't want to attach the
function to the button on page load. When I submit the page, I want to
check some business rules, and based on the response from the database,
if the response is Yes, I need to display a confirmation alert to user.
When the user clicks ok,
then I should take an action, if not, exit out of the subroutine.

Below is the script I'm using in the Submit_Click() subroutine.
__________________________________________________ _________
If Trim(Message) <"" Then
Dim strScript As String = "<script language=JavaScript>"
strScript += "var bAnswer = confirm(""" & Trim(Message) & """);"
strScript += "</script>"

If (Not Page.IsStartupScriptRegistered("clientScript")) Then
Page.RegisterStartupScript("clientScript", strScript)
End If
End If
__________________________________________________ _________

In the above code, I'm getting a message from the Sql database into
Message variable, and showing that to the user. But I don't have a way
to get the value of what an user have selected from the confirmation
alert box. I don't want to resubmit the form since I would loose some
of the business rules.

If I could pass the javascript variable "bAnswer" value to a server
variable, that would be great.

Any help is appreciated.
Thanks.there is no way to pass the data back other than some sort of postback.
usually you put the answer into a hidden field and do a submit.

your confirm only display when the page is rerendered by the browser, so
you will need to keep the logic for the next pass in state.

render something like:

Page.RegisterStartupScript("myscript",string.Format(@."
<input type=hidden name=txtConfirm id=txtConfirm >
<script>
document.getElementById('txtConfirm').value = confirm('%0');
document.forms[0].submit();
</script>
",Message));

-- bruce (sqlwork.com)

shil wrote:

Quote:

Originally Posted by

Hi all,
>
I am using javascript confirm() function to get user's confirmation
from codebehind after a condition is met. I don't want to attach the
function to the button on page load. When I submit the page, I want to
check some business rules, and based on the response from the database,
if the response is Yes, I need to display a confirmation alert to user.
When the user clicks ok,
then I should take an action, if not, exit out of the subroutine.
>
Below is the script I'm using in the Submit_Click() subroutine.
__________________________________________________ _________
If Trim(Message) <"" Then
Dim strScript As String = "<script language=JavaScript>"
strScript += "var bAnswer = confirm(""" & Trim(Message) & """);"
strScript += "</script>"
>
If (Not Page.IsStartupScriptRegistered("clientScript")) Then
Page.RegisterStartupScript("clientScript", strScript)
End If
End If
__________________________________________________ _________
>
In the above code, I'm getting a message from the Sql database into
Message variable, and showing that to the user. But I don't have a way
to get the value of what an user have selected from the confirmation
alert box. I don't want to resubmit the form since I would loose some
of the business rules.
>
If I could pass the javascript variable "bAnswer" value to a server
variable, that would be great.
>
Any help is appreciated.
Thanks.
>


As Bruce said, you will have to have a sort of postback.

See if this helps you:

http://www.usableasp.net/DeveloperP...erAndClient.htm
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
"shil" <joshilat@.gmail.comwrote in message
news:1167769012.833908.122190@.42g2000cwt.googlegro ups.com...

Quote:

Originally Posted by

Hi all,
>
I am using javascript confirm() function to get user's confirmation
from codebehind after a condition is met. I don't want to attach the
function to the button on page load. When I submit the page, I want to
check some business rules, and based on the response from the database,
if the response is Yes, I need to display a confirmation alert to user.
When the user clicks ok,
then I should take an action, if not, exit out of the subroutine.
>
Below is the script I'm using in the Submit_Click() subroutine.
__________________________________________________ _________
If Trim(Message) <"" Then
Dim strScript As String = "<script language=JavaScript>"
strScript += "var bAnswer = confirm(""" & Trim(Message) & """);"
strScript += "</script>"
>
If (Not Page.IsStartupScriptRegistered("clientScript")) Then
Page.RegisterStartupScript("clientScript", strScript)
End If
End If
__________________________________________________ _________
>
In the above code, I'm getting a message from the Sql database into
Message variable, and showing that to the user. But I don't have a way
to get the value of what an user have selected from the confirmation
alert box. I don't want to resubmit the form since I would loose some
of the business rules.
>
If I could pass the javascript variable "bAnswer" value to a server
variable, that would be great.
>
Any help is appreciated.
Thanks.
>