how to build short code in asp.net [closed] - asp.net

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want build a library function so that when my text comes from database that function filter that text.
Ex : string message= " Hello, world";
so my one function will change the text hello to hi
and another function will change the world to global.
This filter only work if there is any function in my class.
I need this to do in asp.net c#. Is any one have the idea how to do this.

Its not quite clear what you trying to achieve.
But I think you want to do something like this...
var s = YOUR STRING
string[] wordslist = s.Split(' ');
foreach (var word in wordslist )
{
switch (word )
{
case "Hello":
word= word.replace(word,'Hi');
case "World":
etc.....
}
}
I think it will be much easier if you can create database table which hold pair of values.
eg
tblReplace
OldValue NewValue
Hello Hi
World global
So you can do a search for each character with against the OldValue field and if found, you can replace the word with new value..
Hope this helps

Related

How to declare ID as number in Typescript? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have been trying to use type number for the id of one of my entities and I get this error in typescript -
Type '{ id: number; }' does not satisfy the constraint '{ id?: string | undefined; }'.
Types of property 'id' are incompatible.
Type 'number' is not assignable to type 'string | undefined'.
I tried using Guid at first, but when I wanted to upload files to my entity, for some reason type Guid was throwing errors, and wasn't compatible with my SaveFile method. Is this fixable?
Thank you in advance! :)
The library you’re using is expecting the “id” to be a string, so you should just convert your number to string. As VLAZ mentioned in the comment, there’s no problem with the typescript, so it depends on you to adapt to it.
let idNumber = 5264;
const obj = { id: idNumber.toString() };

Wordpress change post title before publish [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am using wordpress 3.5, I create a custom post type called order with title supports only.
Now i want that when this order will publish the title text will be order-#ID , (here ID will be the post ID that going to be publish) nothing else if user write something in title it will not publish it just save with value like order-#23 .
Another thing is any other way to hide title input (i don't wanna show title and editor) but save its value when it publish as like order-#265.
You could hook it at save_post and then update the database to reflect the change in title.
Note that I didn't test the code but it should be something like that:
function save_title( $post_id ){
global $wpdb;
$wpdb->update( $wpdb->posts, array( 'post_title' => 'order-#' . $post_id ), array( 'ID' => $post_id ) );
}
add_action( 'save_post', 'save_title');

Using $_GET[...] in drupal-7 [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I could not find a very proper title for my problem.
I have been trying to incorporate a beautiful search bar(http://loopj.com/jquery-tokeninput) in my drupal website. For this to happen I need to create a php callback function, that should be like: www.mysite.com/search/callback?q=var1.
This is a prerequisite and I cannot do otherwise. However, in drupal you set up the Urls in similar to www.mysite.com/search/callback/var1.
Is there a way to achieve the first one in Drupal?
Thanks :-)
EDIT-1:
What I have already done is :
$items['search/callback'] = array(
'title' => 'Search for String',
'description' => 'callback function for search bar',
'page callback' => 'search_callback',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
)
I can recomend you to explore full example for jQuery UI Autocomplete taxonomy terms here: http://xandeadx.ru/blog/drupal/526. It's originally written in Russian but you can easily read code listings and download packed project. I think you can use the same idea of module.
Some notes:
You can't use q get param for your purpose because it is used by Drupal internally. In jQuery Tokeninput you can set another name of param with queryParam option.
I recommend to check any $_GET param with check_plain().

I need a button to clear cells in a google spreadsheet [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Im making a tool for myself with Google Spreadsheets, and as part of that tool I would like to have a button that clears a specific set of cells. As I understand it, I need to insert a drawing, and then assign a script to that drawing. Trouble is, I dont know the first thing about writing my own so, im here looking for help!
The end goal of this would be for me to have a drawing with a script attached to it that would, when activated, clear the data (make them blank, but leave the color) from cells B7-G7.
Any help you guys could offer would be fantastic!
Such script is very simple, you should look at the tutorials to learn how to do it yourself.
Anyway, here it is:
function clearRange() {
//replace 'Sheet1' with your actual sheet name
var sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1');
sheet.getRange('B7:G7').clearContent();
}
To add a custom menu to your Google spreadsheet, that when clicked, will list all your functions. See the code below
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menubuttons = [ {name: "Clear B7-G7", functionName: "clearRange1"},
{name: "Clear B13-G13", functionName: "clearRange2"}];
ss.addMenu("Custom", menubuttons);
} // note you also have to have functions called clearRange1 and clearRange2 as list below
function clearRange1() { //replace 'Sheet1' with your actual sheet name
var sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1');
sheet.getRange('B7:G7').clearContent();
}
function clearRange2() { //replace 'Sheet1' with your actual sheet name
var sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1');
sheet.getRange('B13:G13').clearContent();
}

Downloading & saving files to disk [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I want to download some files programatically from a remote server.
If you can write the code-snippet in VB, VB.NET, Java, or PHP I can try to solve the rest by myself.
Sample file address:
www.example.com/file1.pdf
www.example.com/file2.pdf
www.example.com/file%20n-1.pdf
It will be helpful if you give solutions to this problem in PHP so I can test in WAMP.
In VB.NET, WebClient makes this trivial:
new WebClient().DownloadFile(url, filename)
In Java, you may use java.net.URL and java.net.URLConnection class methods.
SO Thread - How to download and save a file from internet using Java.
PHP example
<?php
$files = array('file1.pdf', 'file2.pdf', 'filen.pdf');
$remoteBase = 'http://www.site.com/';
$localBase = 'downloads/';
foreach( $files as $f ) {
$fp = fopen($remoteBase.$f, 'rb');
if ( !$fp ) {
echo 'error, ', $f, "\n";
}
else {
file_put_contents($localBase.$f, $fp);
fclose($fp);
}
}

Resources