Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

c#

Posted on 2010-09-16
10
Medium Priority
?
413 Views
Last Modified: 2012-06-27
       uxSendMessage.DefaultRecipient = QueryHelper.GetString("requestid", string.Empty);

how can I rewrite this?
0
Comment
Question by:omegalove
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
10 Comments
 
LVL 21

Expert Comment

by:chapmanjw
ID: 33696448
What are you trying to accomplish?
0
 

Author Comment

by:omegalove
ID: 33696482
QueryHelper.GetString("requestid", string.Empty);
to remove thie queryhelper
#region Assembly CMS.GlobalHelper.dll, v2.0.50727
// C:\inetpub\wwwroot\KenticoCMS\Bin\CMS.GlobalHelper.dll
#endregion

using System;

namespace CMS.GlobalHelper
{
    // Summary:
    //     QueryString helper methods
    public static class QueryHelper
    {
        // Summary:
        //     Returns true if query parameter is present in the query string
        //
        // Parameters:
        //   name:
        //     Query parameter
        public static bool Contains(string name);
        //
        // Summary:
        //     Returns the boolean representation of a query parameter or default value
        //     if parameter is not boolean.
        //
        // Parameters:
        //   name:
        //     Query parameter
        //
        //   defaultValue:
        //     Default value
        public static bool GetBoolean(string name, bool defaultValue);
        //
        // Summary:
        //     Returns the double representation of a query parameter or default value if
        //     parameter is not an integer number.
        //
        // Parameters:
        //   name:
        //     Query parameter
        //
        //   defaultValue:
        //     Default value
        public static double GetDouble(string name, double defaultValue);
        //
        // Summary:
        //     Returns the GUID representation of a query parameter or default value if
        //     parameter is not GUID.
        //
        // Parameters:
        //   name:
        //     Query parameter
        //
        //   defaultValue:
        //     Default value
        public static Guid GetGuid(string name, Guid defaultValue);
        //
        // Summary:
        //     Generates hash for given QueryString
        //
        // Parameters:
        //   input:
        //     Query string starting with '?' or complete url
        //
        // Returns:
        //     SHA256 hash of query string
        public static string GetHash(string input);
        //
        // Summary:
        //     Generates hash for given QueryString
        //
        // Parameters:
        //   input:
        //     Query string starting with '?' or complete url
        //
        //   isQueryString:
        //     Indicates if input is query string or url
        //
        // Returns:
        //     SHA256 hash of query string
        public static string GetHash(string input, bool isQueryString);
        //
        // Summary:
        //     Returns the integer representation of a query parameter or default value
        //     if parameter is not an integer number.
        //
        // Parameters:
        //   name:
        //     Query parameter
        //
        //   defaultValue:
        //     Default value
        public static int GetInteger(string name, int defaultValue);
        //
        // Summary:
        //     Returns query string parameter or default value if query string is not defined.
        //
        // Parameters:
        //   name:
        //     Query parameter
        //
        //   defaultValue:
        //     Default value
        public static string GetString(string name, string defaultValue);
        //
        // Summary:
        //     Returns HTML encoded query string parameter or default value if query string
        //     is not defined.
        //
        // Parameters:
        //   name:
        //     Query parameter
        //
        //   defaultValue:
        //     Default value
        public static string GetText(string name, string defaultValue);
        //
        // Summary:
        //     Validates given QueryString against hash
        //
        // Parameters:
        //   name:
        //     Name of hash parameter in query string
        //
        // Returns:
        //     True if querystring is valid.
        public static bool ValidateHash(string name);
        //
        // Summary:
        //     Validates given QueryString against hash
        //
        // Parameters:
        //   name:
        //     Name of hash parameter in query string
        //
        //   excludedParameters:
        //     Parameters to exclude from hash validation. Multiple names separated by ';'.
        //
        // Returns:
        //     True if querystring is valid.
        public static bool ValidateHash(string name, string excludedParameters);
        //
        // Summary:
        //     Validates given value against hash
        //
        // Parameters:
        //   value:
        //     Value to validate
        //
        //   hash:
        //     Hash value
        //
        // Returns:
        //     True if hash is valid.
        public static bool ValidateHashString(string value, string hash);
    }
}

Open in new window

0
 
LVL 21

Expert Comment

by:chapmanjw
ID: 33696657
If I read it right, you are trying to get a Query String called "requestid".  This is how you would do it if that is the case:

uxSendMessage.DefaultRecipient = Request.QueryString["requestid"].ToString();
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:omegalove
ID: 33696670
but is this doing for empty string?
0
 
LVL 21

Assisted Solution

by:chapmanjw
chapmanjw earned 1000 total points
ID: 33696729
You can do:

string recipient = string.Empty;

try
{
recipient = Request.QueryString["requestid"].ToString();
}
catch
{
recipient = string.Empty;
}

if (recipient == string.Empty)
{
uxSendMessage.DefaultRecipient = "whatever you want it to default to";
}
else
{
uxSendMessage.DefaultRecipient = recipient;
}
0
 
LVL 41

Assisted Solution

by:guru_sami
guru_sami earned 1000 total points
ID: 33696874
If you want to use just once you might want to try this:

uxSendMessage.DefaultRecipient = Request.QueryString["requestid"] == null ? String.Empty : Request.QueryString["requestid"].ToString();

but if you are going to use again in several places the same kind of thing but different way...

uxSendMessage.DefaultRecipient = GetString("requestid", string.Empty);

private string GetString(string value, string defaultvalue)
 {
       return Request.QueryString[value] == null ? defaultvalue : Request.QueryString[value].ToString();
    }
0
 

Accepted Solution

by:
omegalove earned 0 total points
ID: 33701658
There seems to be a mistake here. Split the points between the two fellows.
They have done a terrific job.
0
 

Author Comment

by:omegalove
ID: 33701668
I don't understand what the problem is with the question.
Can one of you gentleman split the points between you two.
0
 

Author Comment

by:omegalove
ID: 33704022
ok thanks.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question