Thursday, March 29, 2012

Pass message

Dear,

Please let me know about querystring or howevery u know.Im tyring to pass one message one aspx page to second aspx page how can i make sentence.plz write down for me with example

This may help:

http://msdn.microsoft.com/msdnmag/issues/07/03/CuttingEdge/default.aspx?loc=en
http://www.codeproject.com/aspnet/QueryString.asp
http://www.eggheadcafe.com/articles/20060427.asp

I hope it helps. Regards,


Check below my blog post

Ways to pass data between webforms

HC

pass multiple values from one aspx page to another

I have to pass values from one aspx page to another. The controls I
have in the first page are:
a textbox, 3 drop down lists, and 2 check boxes, and a submit button.
It is a search page, and the users need not enter values in all the
controls. they can leave the textbox blank, and select values from one
drop down, or any other combinations.
I am trying to pass values with the help of session variables. But I
have multiple if else statements like:
if (ddlCategories.SelectedItem.Value == "")
{
Session["CatID"] = "";
}
else
{
Session["CatID"] = ddlCategories.SelectedItem.Value;
}
The value in the second drop down depends on the value in the first,
and the value in the third drop down depends on the second drop down.
So, its giving me an error saying "Object reference not set to an
instance of the object" if I don't select any value from the first drop
down .(same is the case for the second drop down).
What is the best way yo do this? without all the if else statements,
and may be without using the session variables.
any suggestions?Regarding your object reference error...
You could check for the existance of a selected item first, before trying to
read its value, e.g.
Session["CatID"] = "";
if (ddlCategories.SelectedItem != null)
Session["CatID"] = ddlCategories.SelectedItem.Value;
However I think that there may be a shortcut approach using
ddlCategories.SelectedValue instead. I haven't tested this property without
a selected item, but it will probably return null rather than an exception.
Worth exploring. If it works for you, you may be able to simplify the
constructs to, e.g.;
Session["CatID"] = ddlCategories.SelectedItem.Value;
... with no safety check. If you need to treat "" and null the same (and
have "" as values in your list), you can write a helper function as in;
Session["CatID"] = MakeEmptyStringNull (ddlCategories.SelectedItem.Value);
Regarding your value-passing approach, session variables work fine but makes
the receiving page limited. I prefer to put essentially all navigation
rules into the Url so that users can bookmark search pages reliably, forward
the Url to friends, etc. The cleanest way I've found to do this is to
construct a class that manages the navigation to the target page, and
formulates the Url based on properties, e.g.
class SearchPageUrl
{
public string CatID;
public string Option1;
public string Option2;
/// Generate the Url
public override string ToString ()
{
return String.Format (
"/search/results.aspx?CatID={0}&Option1={1}&Option2={2}",
CatID, Option1, Option2
);
}
/// Determine whether the necessary properties have been set to generate
a valid Url
public bool IsValidUrl ()
{
return true;
}
}
in your onclick;
SearchPageUrl sup = new SearchPageUrl ();
sup.CatID = ddlCategories.SelectedValue;
sup.Option1 = ... ;
sup.Option2 = ... ;
if (sup.IsValidUrl())
Response.Redirect (sup.ToString ());
else
// show error
In your receiving page, you can simplify the querystring processing through
page-level properties, e.g.;
private bool HasCatID
{
get { return Request["CatID"] != null; }
}
private int CatID
{
get { return Int32.Parse (Request["CatID"]); }
}
Which keeps the code in your page clean, and centralizes the parsing of your
querystring propeties.
Clearly this is a bit more code than the Session var approach but it's worth
considering. Most users expect the pages to be bookmarkable.
/// M
"macyp" <vradhika@.gmail.com> wrote in message
news:1106755384.274484.211140@.c13g2000cwb.googlegroups.com...
> I have to pass values from one aspx page to another. The controls I
> have in the first page are:
> a textbox, 3 drop down lists, and 2 check boxes, and a submit button.
> It is a search page, and the users need not enter values in all the
> controls. they can leave the textbox blank, and select values from one
> drop down, or any other combinations.
> I am trying to pass values with the help of session variables. But I
> have multiple if else statements like:
> if (ddlCategories.SelectedItem.Value == "")
> {
> Session["CatID"] = "";
> }
> else
> {
> Session["CatID"] = ddlCategories.SelectedItem.Value;
> }
> The value in the second drop down depends on the value in the first,
> and the value in the third drop down depends on the second drop down.
> So, its giving me an error saying "Object reference not set to an
> instance of the object" if I don't select any value from the first drop
> down .(same is the case for the second drop down).
> What is the best way yo do this? without all the if else statements,
> and may be without using the session variables.
> any suggestions?
>
Hi Macyp,
Checking that the SelectedIndex DropDownList property is not equal to
-1 before retrieving the SelectedItem.Value property should solve your
"Object referenct" problem. Sample:
if (ddlCategories.SelectedIndex != -1)
Tod Birdsall
http://tod1d.blogspot.com

pass multiple values from one aspx page to another

I have to pass values from one aspx page to another. The controls I
have in the first page are:
a textbox, 3 drop down lists, and 2 check boxes, and a submit button.
It is a search page, and the users need not enter values in all the
controls. they can leave the textbox blank, and select values from one
drop down, or any other combinations.
I am trying to pass values with the help of session variables. But I
have multiple if else statements like:

if (ddlCategories.SelectedItem.Value == "")
{
Session["CatID"] = "";
}
else
{
Session["CatID"] = ddlCategories.SelectedItem.Value;
}

The value in the second drop down depends on the value in the first,
and the value in the third drop down depends on the second drop down.
So, its giving me an error saying "Object reference not set to an
instance of the object" if I don't select any value from the first drop
down .(same is the case for the second drop down).

What is the best way yo do this? without all the if else statements,
and may be without using the session variables.
any suggestions?Regarding your object reference error...

You could check for the existance of a selected item first, before trying to
read its value, e.g.

Session["CatID"] = "";
if (ddlCategories.SelectedItem != null)
Session["CatID"] = ddlCategories.SelectedItem.Value;

However I think that there may be a shortcut approach using
ddlCategories.SelectedValue instead. I haven't tested this property without
a selected item, but it will probably return null rather than an exception.
Worth exploring. If it works for you, you may be able to simplify the
constructs to, e.g.;

Session["CatID"] = ddlCategories.SelectedItem.Value;

... with no safety check. If you need to treat "" and null the same (and
have "" as values in your list), you can write a helper function as in;

Session["CatID"] = MakeEmptyStringNull (ddlCategories.SelectedItem.Value);

Regarding your value-passing approach, session variables work fine but makes
the receiving page limited. I prefer to put essentially all navigation
rules into the Url so that users can bookmark search pages reliably, forward
the Url to friends, etc. The cleanest way I've found to do this is to
construct a class that manages the navigation to the target page, and
formulates the Url based on properties, e.g.

class SearchPageUrl
{
public string CatID;
public string Option1;
public string Option2;

/// Generate the Url
public override string ToString ()
{
return String.Format (
"/search/results.aspx?CatID={0}&Option1={1}&Option2={2}",
CatID, Option1, Option2
);
}

/// Determine whether the necessary properties have been set to generate
a valid Url
public bool IsValidUrl ()
{
return true;
}
}

in your onclick;

SearchPageUrl sup = new SearchPageUrl ();
sup.CatID = ddlCategories.SelectedValue;
sup.Option1 = ... ;
sup.Option2 = ... ;

if (sup.IsValidUrl())
Response.Redirect (sup.ToString ());
else
// show error

In your receiving page, you can simplify the querystring processing through
page-level properties, e.g.;

private bool HasCatID
{
get { return Request["CatID"] != null; }
}
private int CatID
{
get { return Int32.Parse (Request["CatID"]); }
}

Which keeps the code in your page clean, and centralizes the parsing of your
querystring propeties.

Clearly this is a bit more code than the Session var approach but it's worth
considering. Most users expect the pages to be bookmarkable.

/// M

"macyp" <vradhika@.gmail.com> wrote in message
news:1106755384.274484.211140@.c13g2000cwb.googlegr oups.com...
> I have to pass values from one aspx page to another. The controls I
> have in the first page are:
> a textbox, 3 drop down lists, and 2 check boxes, and a submit button.
> It is a search page, and the users need not enter values in all the
> controls. they can leave the textbox blank, and select values from one
> drop down, or any other combinations.
> I am trying to pass values with the help of session variables. But I
> have multiple if else statements like:
> if (ddlCategories.SelectedItem.Value == "")
> {
> Session["CatID"] = "";
> }
> else
> {
> Session["CatID"] = ddlCategories.SelectedItem.Value;
> }
> The value in the second drop down depends on the value in the first,
> and the value in the third drop down depends on the second drop down.
> So, its giving me an error saying "Object reference not set to an
> instance of the object" if I don't select any value from the first drop
> down .(same is the case for the second drop down).
> What is the best way yo do this? without all the if else statements,
> and may be without using the session variables.
> any suggestions?
Hi Macyp,

Checking that the SelectedIndex DropDownList property is not equal to
-1 before retrieving the SelectedItem.Value property should solve your
"Object referenct" problem. Sample:

if (ddlCategories.SelectedIndex != -1)
Tod Birdsall
http://tod1d.blogspot.com

Pass multiple parameters into pages querystring property from jscript

This is a basic question but I cant seem to find the answer anywhere and
have never tried it before.

Here's one of many syntax I'm trying, but should at least show you what I'm
trying to do:

parent.data.frameElement.src="data.aspx?Task=CartAddNew & sku=" + ItemSku;

where there's 2 parameters, Task and sku, and I'm trying to pass a text
value of "CartAddNew" to the Task parameter and a value from the ItemSku
variable to the sku parameter.

Thanks.

--
moondaddy@dotnet.itags.org.nospam.comI found the answer in another posting when I searched on "Pass"

The correct way to separate the 2 parameters and their value assignments is
with a & and no spaces on each side. I had tried it with a space on each
side which made it fail. Here's what worked for me:

parent.data.frameElement.src="data.aspx?Task=CartAddNew&sku=" + sku;

refer to my post below for clarification on the value assignments.

--
moondaddy@.nospam.com
"moondaddy" <moondaddy@.nospam.com> wrote in message
news:%23C96wii$DHA.3960@.TK2MSFTNGP10.phx.gbl...
> This is a basic question but I cant seem to find the answer anywhere and
> have never tried it before.
> Here's one of many syntax I'm trying, but should at least show you what
I'm
> trying to do:
> parent.data.frameElement.src="data.aspx?Task=CartAddNew & sku=" + ItemSku;
> where there's 2 parameters, Task and sku, and I'm trying to pass a text
> value of "CartAddNew" to the Task parameter and a value from the ItemSku
> variable to the sku parameter.
> Thanks.
> --
> moondaddy@.nospam.com

pass more than one parm

hey all,
i'm in a template column of a gridview. i have a hyperlink in the Item
Template and i'm trying to do a custom binding expression to it. So far i
have the following:
Eval("FILE_ID", "~/ViewFile.aspx?Id={0}")
Is there a way to pass more than one parm? If so, could someone please show
me the syntax?
thanks,
rodchar"rodchar" wrote:
> hey all,
> i'm in a template column of a gridview. i have a hyperlink in the Item
> Template and i'm trying to do a custom binding expression to it. So far i
> have the following:
> Eval("FILE_ID", "~/ViewFile.aspx?Id={0}")
> Is there a way to pass more than one parm? If so, could someone please sho
w
> me the syntax?
> thanks,
> rodchar
rod,
Inside your binding syntax, you'll have to call another formating function
that takes multiple arguments. Try this:
<ItemTemplate>
<asp:HyperLink ID="lnkTest" runat="server"
NavigateUrl='<%# String.Format("~/Temp.aspx?id={0}&id2={1}", Eval("id1"),
Eval("id2")) %>' Text="Link 1"></asp:HyperLink>
</ItemTemplate>
If your binding is more complicated than what string.Format() can handle
then declare a function in your codebehind and call that function inside you
r
templated column. Something like:
inside your codebehind declare a function...
public string FormatURL(string arg1, string arg2)
{
return string.Format("~/Temp.aspx?id={0}&id1={1}", arg1, arg2);
}
<ItemTemplate>
<asp:HyperLink ID="lnkAnotherTest" runat="server"
NavigateUrl='<%# FormatURL(Eval("id1").ToString(), Eval("id2")).ToString()
%>' Text="Link 2">
</asp:HyperLink>
</ItemTemplate>
Hope this helps,
Jason Vermillion
awesome, thank you for the help. rod.
"Jason Vermillion" wrote:

> "rodchar" wrote:
> rod,
> Inside your binding syntax, you'll have to call another formating function
> that takes multiple arguments. Try this:
> <ItemTemplate>
> <asp:HyperLink ID="lnkTest" runat="server"
> NavigateUrl='<%# String.Format("~/Temp.aspx?id={0}&id2={1}", Eval("id1"),
> Eval("id2")) %>' Text="Link 1"></asp:HyperLink>
> </ItemTemplate>
> If your binding is more complicated than what string.Format() can handle
> then declare a function in your codebehind and call that function inside y
our
> templated column. Something like:
> inside your codebehind declare a function...
> public string FormatURL(string arg1, string arg2)
> {
> return string.Format("~/Temp.aspx?id={0}&id1={1}", arg1, arg2);
> }
>
> <ItemTemplate>
> <asp:HyperLink ID="lnkAnotherTest" runat="server"
> NavigateUrl='<%# FormatURL(Eval("id1").ToString(), Eval("id2")).ToString()
> %>' Text="Link 2">
> </asp:HyperLink>
> </ItemTemplate>
> Hope this helps,
> Jason Vermillion
>

pass my dropdownlist

hey all,
i'm in vs2005 designer view editing a formview's edit template. i have a
dropdownlist and i'm trying to bind the SelectedValue to a custom expression
.
i was wondering if it is possible to pass the dropdownlist object down to th
e
code-behind? i tried using the this keyword but that didn't work.
thanks,
rodcharCan you please eloborate a little more?
Are you trying to access the Dropdownlist in the designer or in some
routine in the code behind?
If it is in the code behind of the samepage where the dropdown is declared,
I do not see any problem accessing it.
Can you give an example of your code?
--
>Thread-Topic: pass my dropdownlist
>thread-index: Acg2ih2bZVRS0qv3TbWr/MzGXJ0Yjg==
>X-WBNR-Posting-Host: 24.214.205.110
>From: examnotes <rodchar@.discussions.microsoft.com>
>Subject: pass my dropdownlist
>Date: Tue, 4 Dec 2007 07:27:01 -0800
>Lines: 8
>Message-ID: <31752D5F-72C8-4B2C-ACA5-E868CEF35F42@.microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2992
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Path: TK2MSFTNGHUB02.phx.gbl
>Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.dotnet.framework.aspnet:52357
>NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>hey all,
>i'm in vs2005 designer view editing a formview's edit template. i have a
>dropdownlist and i'm trying to bind the SelectedValue to a custom
expression.
>i was wondering if it is possible to pass the dropdownlist object down to
the
>code-behind? i tried using the this keyword but that didn't work.
>thanks,
>rodchar
>
Thank You,
Nanda Lella,
This Posting is provided "AS IS" with no warranties, and confers no rights.
you're right, i just realized how obvious my question was after i posted. i
apologize.
"Nanda Lella[MSFT]" wrote:

> Can you please eloborate a little more?
> Are you trying to access the Dropdownlist in the designer or in some
> routine in the code behind?
> If it is in the code behind of the samepage where the dropdown is declared
,
> I do not see any problem accessing it.
> Can you give an example of your code?
> --
> expression.
> the
> --
> Thank You,
> Nanda Lella,
> This Posting is provided "AS IS" with no warranties, and confers no rights
.
>

pass my dropdownlist

hey all,
i'm in vs2005 designer view editing a formview's edit template. i have a
dropdownlist and i'm trying to bind the SelectedValue to a custom expression.
i was wondering if it is possible to pass the dropdownlist object down to the
code-behind? i tried using the this keyword but that didn't work.

thanks,
rodcharCan you please eloborate a little more?
Are you trying to access the Dropdownlist in the designer or in some
routine in the code behind?
If it is in the code behind of the samepage where the dropdown is declared,
I do not see any problem accessing it.

Can you give an example of your code?

-------

Quote:

Originally Posted by

>Thread-Topic: pass my dropdownlist
>thread-index: Acg2ih2bZVRS0qv3TbWr/MzGXJ0Yjg==
>X-WBNR-Posting-Host: 24.214.205.110
>From: =?Utf-8?B?cm9kY2hhcg==?= <rodchar@.discussions.microsoft.com>
>Subject: pass my dropdownlist
>Date: Tue, 4 Dec 2007 07:27:01 -0800
>Lines: 8
>Message-ID: <31752D5F-72C8-4B2C-ACA5-E868CEF35F42@.microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
>charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2992
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Path: TK2MSFTNGHUB02.phx.gbl
>Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.dotnet.framework.aspnet:52357
>NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>hey all,
>i'm in vs2005 designer view editing a formview's edit template. i have a
>dropdownlist and i'm trying to bind the SelectedValue to a custom


expression.

Quote:

Originally Posted by

>i was wondering if it is possible to pass the dropdownlist object down to


the

Quote:

Originally Posted by

>code-behind? i tried using the this keyword but that didn't work.
>
>thanks,
>rodchar
>


--

Thank You,
Nanda Lella,

This Posting is provided "AS IS" with no warranties, and confers no rights.
you're right, i just realized how obvious my question was after i posted. i
apologize.

"Nanda Lella[MSFT]" wrote:

Quote:

Originally Posted by

Can you please eloborate a little more?
Are you trying to access the Dropdownlist in the designer or in some
routine in the code behind?
If it is in the code behind of the samepage where the dropdown is declared,
I do not see any problem accessing it.
>
Can you give an example of your code?
>
-------

Quote:

Originally Posted by

Thread-Topic: pass my dropdownlist
thread-index: Acg2ih2bZVRS0qv3TbWr/MzGXJ0Yjg==
X-WBNR-Posting-Host: 24.214.205.110
From: =?Utf-8?B?cm9kY2hhcg==?= <rodchar@.discussions.microsoft.com>
Subject: pass my dropdownlist
Date: Tue, 4 Dec 2007 07:27:01 -0800
Lines: 8
Message-ID: <31752D5F-72C8-4B2C-ACA5-E868CEF35F42@.microsoft.com>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2992
Newsgroups: microsoft.public.dotnet.framework.aspnet
Path: TK2MSFTNGHUB02.phx.gbl
Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.dotnet.framework.aspnet:52357
NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

hey all,
i'm in vs2005 designer view editing a formview's edit template. i have a
dropdownlist and i'm trying to bind the SelectedValue to a custom


expression.

Quote:

Originally Posted by

i was wondering if it is possible to pass the dropdownlist object down to


the

Quote:

Originally Posted by

code-behind? i tried using the this keyword but that didn't work.

thanks,
rodchar


>
--
>
Thank You,
Nanda Lella,
>
This Posting is provided "AS IS" with no warranties, and confers no rights.
>
>