Showing posts with label webform. Show all posts
Showing posts with label webform. Show all posts

Thursday, March 29, 2012

passing values between different projects

Hi,
I h ave one project in C# and the other one in vb.net. I want one of the VB.net webforms to pass a value to C#'s webform. how can I do this ?

Thanks,If they're published to the same website, you can post the values in the Query String or store the values into session. The difference in languages does not matter.

passing values from main webform to include template pages

View a printable version of this message!I'm new to ASP.Net... I have a web page (myform.aspx) that is put together using 3 include files, header.cscx, left.cscx, & footer.cscx (each has their own .cscx.vb files). I want to assign some custom values on myform.aspx.vb, how can I get these custom values in my one of my includes files, ie. header.cscx.vb?
'**********This is myform.aspx*************
<%@dotnet.itags.org. Register TagPrefix="UC" TagName="footer" src="http://pics.10026.com/?src=footer.ascx"%>
<%@dotnet.itags.org. Register TagPrefix="UC" TagName="left" src="http://pics.10026.com/?src=left.ascx"%>
<%@dotnet.itags.org. Register TagPrefix="UC" TagName="header" src="http://pics.10026.com/?src=header.ascx"%>
<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false" Codebehind="myform.aspx.vb" Inherits="intranet.myform"%>
<UC:header id="header" runat="server" />
<UC:left id="left" runat="server" />
<TABLE><TR><td>My contents go here...</td></TR></TABLE>
<UC:footer id="footer" runat="server" />

'**********This is myform.aspx.vb*************
Public Class myform
Inherits System.Web.UI.Page
Protected WithEvents lblPageTitle As System.Web.UI.WebControls.Label
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblPageTitle.Text = "Welcome to my home page!"
End Sub
End Class

'**********This is header.ascx*************
<%@dotnet.itags.org. Control Language="vb" AutoEventWireup="false" Codebehind="header.ascx.vb" Inherits="intranet.header" %>
'I don't have any HTML code here yet (all are in header.acsx.vb) b/c I'm still working on the sepration between HTML design and codebehind page.

'**********This is header.ascx.vb*************
Public Class header
Inherits System.Web.UI.UserControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'How can I get the value of lblPageTitle here so I can display it in the HTML Title tag??
'I have other values that I want to pass to this page too, but for this example, I'm just trying to get the value of lblPageTitle from myform.aspx.vb
Response.Write("<HTML><HEAD>")
Response.Write("<title>lblPageTitle</title>")
Response.Write("</HEAD><BODY>")
...
End Sub
End Class1) Cookie
2) Session Variable
3) Query String
I think any of these will work for what you're describing. You'retrying to get som value to be accessible to your user controls from themain page.

Have you thought of using properties inside the usercontrols?
check this please:
An Extensive Examination of User Controls
The best reference to UserControls
Regards
Thank you so much, it's exactly what I need!
That is great, Im happy for you.
regards

Saturday, March 24, 2012

Passing Variables between web forms

Hi There,
My question is as following,
I have a webform (Webform1) which contains one label control and command
button, when the user clicks the button another webform (Webform2) appears,
webform2 contains only one control which is the Calendar control, I want to
do the following
1- when the user selects a date from the webforms, I want the value
(selected date) appears in the label control in the webform1
2- Webform2 to be closed automatically after the date selection
Kind regards and thanks in advancesearch MSDN for showModalDialog method. That will do just what you're
looking for.
Dale
"Aitham alama" <h_salama@.yahoo.com> wrote in message
news:eSfH8gcZEHA.3716@.TK2MSFTNGP11.phx.gbl...
> Hi There,
> My question is as following,
> I have a webform (Webform1) which contains one label control and command
> button, when the user clicks the button another webform (Webform2)
appears,
> webform2 contains only one control which is the Calendar control, I want
to
> do the following
> 1- when the user selects a date from the webforms, I want the value
> (selected date) appears in the label control in the webform1
> 2- Webform2 to be closed automatically after the date selection
> Kind regards and thanks in advance
>

Passing Variables between web forms

Hi There,

My question is as following,

I have a webform (Webform1) which contains one label control and command
button, when the user clicks the button another webform (Webform2) appears,
webform2 contains only one control which is the Calendar control, I want to
do the following

1- when the user selects a date from the webforms, I want the value
(selected date) appears in the label control in the webform1
2- Webform2 to be closed automatically after the date selection

Kind regards and thanks in advancesearch MSDN for showModalDialog method. That will do just what you're
looking for.

Dale

"Aitham alama" <h_salama@.yahoo.com> wrote in message
news:eSfH8gcZEHA.3716@.TK2MSFTNGP11.phx.gbl...
> Hi There,
> My question is as following,
> I have a webform (Webform1) which contains one label control and command
> button, when the user clicks the button another webform (Webform2)
appears,
> webform2 contains only one control which is the Calendar control, I want
to
> do the following
> 1- when the user selects a date from the webforms, I want the value
> (selected date) appears in the label control in the webform1
> 2- Webform2 to be closed automatically after the date selection
> Kind regards and thanks in advance

Wednesday, March 21, 2012

PassingObjectstoWebForms

I have an object that gets created when the first ASP.NET webform, of
the web app, is opened. I need to pass this object to other webforms as
they are opened and keep the scope in the same session. How can I do this?

ThanksHI J,

You can store the object into a Session var and pick it up in following
forms. This works well assuming that the object you are storing is
serializable.

If you're using Server.Transfer() or Server.Excute() you can also use
Context.Items() to store request specific info to pass to transferred pages.

+++ Rick --

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
-----------
Making waves on the Web

"J" <j@.netscape.net> wrote in message
news:ODlq6J5AEHA.3400@.tk2msftngp13.phx.gbl...
> I have an object that gets created when the first ASP.NET webform, of
> the web app, is opened. I need to pass this object to other webforms as
> they are opened and keep the scope in the same session. How can I do
this?
> Thanks

Friday, March 16, 2012

Password field is cleared after postback

Hello,
I am developing a C# asp.net application.
I have a webform which contains 2 dropdowns and a textbox with
type="password".
On "SelectedIndexChanged" event of the first dropdown, there is a postback,
in order to fill the second dropdown according to the value selected in the
first dropdown.
The problem is that the password field which has been filled up before is
cleared after postback.
I know this is for security, but is there a way to keep the password'
Thank youdana lees wrote:

> Hello,
> I am developing a C# asp.net application.
> I have a webform which contains 2 dropdowns and a textbox with
> type="password".
> On "SelectedIndexChanged" event of the first dropdown, there is a
> postback, in order to fill the second dropdown according to the value
> selected in the first dropdown.
> The problem is that the password field which has been filled up before is
> cleared after postback.
> I know this is for security, but is there a way to keep the password'
> Thank you
Yes, you can add a "value" attribute to the password textbox on postback:
txtPassword.Attributes.Add("value", txtPassword.Text)
Ben
I have tried that and it didn't work. The field stayed empty...
"Ben Amada" <ben@.REpoMOweVErpick.com> wrote in message
news:OaFdNkA8FHA.3804@.TK2MSFTNGP12.phx.gbl...
> dana lees wrote:
>
is
> Yes, you can add a "value" attribute to the password textbox on postback:
> txtPassword.Attributes.Add("value", txtPassword.Text)
> Ben
>
dana lees wrote:

> I have tried that and it didn't work. The field stayed empty...
Hmm... not sure why that doesn't work. Are you using .NET v2.0? I've done
it in v1.1 without any problems.
Another option is to manually set the value of the password field via
JavaScript. There are several ways to do this.
One way is to create a hidden input field. On postback, put the password in
the hidden input field (i.e. txtHiddenPwd.Value = txtPwd.Text). Then with a
startup script or via the body tag's onload attribute, set the value of the
password textbox to the value of the hidden input field.
Ben
I am using version 1.1.
On debug, I see that i do have the value of the password after postback, i
just can't set the textbox with that value.
I have tried also java script:
document.all.txtPassword.InnerText = "some text";
and this doesn't work as well...
I don't need to use a hidden textbox becuase i do have the value after
postback, i just can't set the textbox's value to that value...
"Ben Amada" <ben@.REpoMOweVErpick.com> wrote in message
news:u2Kz1wA8FHA.4076@.tk2msftngp13.phx.gbl...
> dana lees wrote:
>
> Hmm... not sure why that doesn't work. Are you using .NET v2.0? I've
done
> it in v1.1 without any problems.
> Another option is to manually set the value of the password field via
> JavaScript. There are several ways to do this.
> One way is to create a hidden input field. On postback, put the password
in
> the hidden input field (i.e. txtHiddenPwd.Value = txtPwd.Text). Then with
a
> startup script or via the body tag's onload attribute, set the value of
the
> password textbox to the value of the hidden input field.
> Ben
>
dana lees wrote:

> I am using version 1.1.
> On debug, I see that i do have the value of the password after postback, i
> just can't set the textbox with that value.
> I have tried also java script:
> document.all.txtPassword.InnerText = "some text";
> and this doesn't work as well...
> I don't need to use a hidden textbox becuase i do have the value after
> postback, i just can't set the textbox's value to that value...
Server-side you can't set the textbox's value to the password. However,
with JavaScript (client-side) you should be able to set the value of the
textbox with or without a hidden input field. Without a hidden input field,
you could simply add a runat="server" attribute to the <body> tag, then on
the server-side during a postback, you can add an "onload" attribute to the
body tag specifying the password value. Like this:
===== HTML =====
<body id="myBody" runat="server">
===== Code-Behind =====
myBody.Attributes.Add("onload", _
"document.getElementById('txtPassword').value = '" & _
txtPassword.Text & "'")
(the C# syntax should be similar)
Also, in the code-behind, if Visual Studio doesn't recognize the "myBody"
control (which happens sometimes), you'll probably have to manually add the
control declaration to the code-behind:
Dim myBody As HtmlControls.HtmlGenericControl
... or instead of adding an "onload" attribute to the body tag, you could
use the RegisterStartupScript method to set the password textbox value.
Ben
dana lees wrote:

> I have tried also java script:
> document.all.txtPassword.InnerText = "some text";
> and this doesn't work as well...
By the way, what do you mean that it "doesn't work as well"? How about :
document.getElementById('txtPassword').value = "some text";
Ben
It worked, when using
document.getElementById('txtPassword').value = "some text";
Thank you very much :-)
"Ben Amada" <ben@.REpoMOweVErpick.com> wrote in message
news:%23G3ExQB8FHA.3200@.TK2MSFTNGP11.phx.gbl...
> dana lees wrote:
>
> By the way, what do you mean that it "doesn't work as well"? How about :
> document.getElementById('txtPassword').value = "some text";
> Ben
>
Dana,
As Ben suggested you can use assword.Attributes.Add("value",
txtPassword.Text) to set the password .But instead of txtPassword.Text you
should retrieve password text using
txtPassword.Attributes["value"].ToString().
"dana lees" wrote:

> I have tried that and it didn't work. The field stayed empty...
> "Ben Amada" <ben@.REpoMOweVErpick.com> wrote in message
> news:OaFdNkA8FHA.3804@.TK2MSFTNGP12.phx.gbl...
> is
>
>
Check out:
http://groups.google.com/group/micr...de23fa30643fa4e
and
http://groups.google.com/group/micr...f9f3be06c4f0396
(watch for link brakage). Basically, you need to reset the value manually
via Password.Attributes.Add("value", Password.Text) or something
karl
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
"dana lees" <danal@.idc.ac.il> wrote in message
news:%23jWQj9$7FHA.4036@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I am developing a C# asp.net application.
> I have a webform which contains 2 dropdowns and a textbox with
> type="password".
> On "SelectedIndexChanged" event of the first dropdown, there is a
> postback,
> in order to fill the second dropdown according to the value selected in
> the
> first dropdown.
> The problem is that the password field which has been filled up before is
> cleared after postback.
> I know this is for security, but is there a way to keep the password'
> Thank you
>