Retrieve Resource Values Programmatically in asp.net C# - c#

I want to get strings from my App_resource programmatically because I get from the DB a keyword with the name of the string in the app_resource mlbRes.
I have a stored procedure that indicates what the user should do next, sending a string that corresponds to a string in my app_resources file. I can do it with a switch, but that will only complicate my code.
As you can see in the following screenshot, I've tried different approaches, but none worked so far.
screenshot
Can anyone point me out what I'm doing wrong?
Thanks in advance.

Use this Syntax Here mlbRes is your resource file name
string value= Resources.mlbRes.ResourceManager.GetString("StringName");

Related

Revit API - How to read correct BuiltInParameter values from a list of FamilyParameter

I'm trying to read BuiltInParameter, Parameter Name, Parameter Type etc from a list of FamilyParameter instance. The code I'm using to read the FamilyParameter is written here on the GitHub. The output of the code is here. As you can see, there are a lot of INVALID values in BuiltInParameter Column. But when I cross check the value of BuiltInParameter, it is not INVALID.
I'm wondering if someone could explain, how could I get the valid BuiltInParameter data from the list FamilyParameter. Appreciate any help. Thank you.
Original Source
You should probably take a look at BipChecker, the built-in parameter checker. Looking at the output you are generating, it probably already does all you require.

C# and Swedish characters

I am trying to save this Swedish string "120918_demo_öar.jpg" to MySQL database. Strangely, the value that is getting stored in the database is "120918_demo_o¨ar.jpg"
Initially, I thought this was a MySQL issue, but found out that that was not the case.
In code, I get this string "120918_demo_öar.jpg" by parsing XML stored in an SQL Server Database table. The string is stored to a variable named imgName
If I do,
imgName == "120918_demo_öar.jpg", it gives false and
imgName.Equals("120918_demo_öar.jpg") also gives false
I have no idea what the issue is. Please help
Thanks in advance
Vivek

Pulling String from Database. Says Cannot Implicitly Convert to 'string'

In my database I have a field that is storing a simple string. The user can edit it, as it will be used as the text on a button later.
The storing of the string is working fine, but when I try to pull the string out again in case the user wants to edit it, the code behind is showing me the error:
Cannot implicitly convert type 'store.storeProductsDataTable' to 'string'
I have an XSD with a super basic get statement to retrieve the text and the field in the database is flagged as type text. Like I mentioned, it's storing the string great. Also on the same page, it successfully retrieves the product's name, description, price, etc using the same method.
All I am trying to do with the string is apply it to a textbox with the following code:
customBuyNowText.Text = pdb.getBuyNowText(pID);
Any suggestions on what I could be missing for it to cause this error?
I'll try this yet again in C#: if it's a datatable, try:
DataTable dt = pdb.getBuyNowText(pID);
customBuyNowText.Text = dt.Rows[0]["your_column_name"].ToString();

Problem passing filename between pages (query string)

I've tried and tried but just cannot get a hold of this so let me explain my problem.I have a survey website using xml survey files. On one page I have a category menu which passes relative surveys filename to another page in the redirect as a query string.
~/websurvey.aspx?Survey=gamesurvey.xml
so the name of the survey file is gamesurvey.xml. On another page I have the following to read the filename into a string.
string c = Request.QueryString["Survey"];
now here lies my problem. The control that I have to pass the filename to does not recognise any attempts I make at trying to "dereference" the string. Here is the part in question.
<sstchur:WebSurvey id = "ws"
SurveyFile = "gamesurvey.xml"
AnswersFile = "answers.xml"
runat = "server"/>
</form>
Above where you see gamesurvey.xml thats where I need to pass the string. Here it is hardcoded.This is a problem because I want to be able to call any survey by way of query string without having to make new pages for each of them.
If I put things like
""+c+"" or .toString() or SurveyFile = c
it tells me the server tag is not well formed.
To sum up my problem I need to pass a filepath directly from page to page. By the way, when I put SurveyFile = c I get a pageload error saying the file c cannot be found, i.e. this control will only take a filename not a variable containing it.
Sorry if this is hard to understand but my head is just melted with it now I had to ask.
Any help would be appreciated.
The control im using is the WebSurvey control 4GuysFromRolla and yes I have checked all the documentation and the few forum posts related to it.
And what prevents you from setting that control property in your code-behind?
If you've your "page.aspx.cs", just do that in the Page.Init Page.Load event and you'll be fine!
Maybe I'm wrong and you can't use code-behind or something like that.
i am giving u few options
use
SurveyFile= <% c %>
or since you are not passing the full file path so ur file is not found. give it like ~//root//directory//filename.extension
or may be
u can find some methods to set that parameter using the code behind page.
do tick my answer correct if found useful

Pass string parameter to SqlDataSource in asp.net

i have placed a SqlDataSource component on my aspx page but while configuring the SqlDataSource in the "Test Query" Step I am passing the following parameters :
But when i click ok it returns following error:
This error occurs when i pass the string :
INFO, WARN, ERROR,
I have tried a lot of combinations but nothing works. It works only if i pass one of the three words in single quotes like this :
'ERROR'
Infact the INFO WARN and ERROR are the various levels available in the table. Each record can have only one level and in the sql query i am using IN("-----") to match the criteria, hope you understand.
Any idea to pass the string with comas between them will be highly appreciated.
After you create the page with the dialogue helpers, just switch to code view of your html and change them by hand on the created code...
I have resolved the problem by passing each level in single quotes without , after the last level as shown in the image below:
Anyway thanks for your help Aristos!

Categories

Resources