Using Page.RegisterClientsideScript with arguments

I need to use a javascript and set a couple arguments in it from the
vb.net code behind. I can get this working

(sb is a stringbuilder)

Page.RegisterClientsideScript("testscript()", sb.ToString());

but what I need is...

Page.RegisterClientsideScript("testscript", sb.ToString("string1",
"string2"));

Thanks!

0
Dave
10/9/2010 10:01:49 AM
dotnet.framework.aspnet 1425 articles. 0 followers. Follow

2 Replies
4162 Views

Similar Articles

[PageSpeed] 0

On Sat, 09 Oct 2010 05:01:49 -0500, Dave wrote:

>I need to use a javascript and set a couple arguments in it from the
>vb.net code behind. I can get this working
>
>(sb is a stringbuilder)
>
>Page.RegisterClientsideScript("testscript()", sb.ToString());
>
>but what I need is...
>
>Page.RegisterClientsideScript("testscript", sb.ToString("string1",
>"string2"));
>

The obvious problem is the StringBuilder type's ToString method
doesn't have an overload that takes two strings as arguments and
returns the desired script. An extension method could be written or a
different way to return the script could be used.

Here is an example of how I build and register client-side scripts.

string key = "ShowHideRefinementsScript";
string script = getShowHideRefinementScript();
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), key,
script, true);


regards
A.G.
0
Registered
10/9/2010 11:53:20 AM
assuming that sb contents contain your formatting string and that striing1 
and string2 are the agruments ,
change
    sb.ToString("string1","string2")
to
    string.Format(sb.ToString() , "string1" , "string2" )


"Registered User" <n4jvp@ix.netcom.com> wrote in message 
news:d4l0b6dab8nnjtinjtmgtv9r3i5a899eak@4ax.com...
> On Sat, 09 Oct 2010 05:01:49 -0500, Dave wrote:
>
>>I need to use a javascript and set a couple arguments in it from the
>>vb.net code behind. I can get this working
>>
>>(sb is a stringbuilder)
>>
>>Page.RegisterClientsideScript("testscript()", sb.ToString());
>>
>>but what I need is...
>>
>>Page.RegisterClientsideScript("testscript", sb.ToString("string1",
>>"string2"));
>>
>
> The obvious problem is the StringBuilder type's ToString method
> doesn't have an overload that takes two strings as arguments and
> returns the desired script. An extension method could be written or a
> different way to return the script could be used.
>
> Here is an example of how I build and register client-side scripts.
>
> string key = "ShowHideRefinementsScript";
> string script = getShowHideRefinementScript();
> Page.ClientScript.RegisterClientScriptBlock(this.GetType(), key,
> script, true);
>
>
> regards
> A.G. 


0
gerry
10/9/2010 2:40:30 PM
Reply:

Similar Artilces:

Invalid Procedure Call or Arguments
Hi, I got this error ("Invalid Procedure Call or Arguments") when run this code: 'Delete drawing files Set fs = CreateObject("Scripting.FileSystemObject") Set fld = fs.GetFolder(pubWorkingDir & "Drawings\") Set rsc = dbs.OpenRecordset("SELECT * FROM tblDrawings WHERE ID=" & tempItemID, dbOpenDynaset) rsc.MoveFirst Do While Not rsc.EOF If Dir(pubWorkingDir & "Drawings\" & rsc!DrawingFile) <> "" Then fld.Files(pubWorkingDir & "Drawings\" & rsc! DrawingFile).Delete True ...

Identical Name on multiple workbook pages
As a hardened Excel/VBA nut, I'm probably going to be really embarrased when I get the answer to this, but here goes... I have a workbook containing a worksheet that records weekly data. I have a named range ("Data") which I select then clear, via GoTo. Each week, I copy the latest week's worksheet and create a new worksheet for the new week. And each week, I select the range "Data" and clear it in the most recently created worksheet. the thing is, I always thought that Range names were unique across a workbook, and that you couldn't have the same Range N...

how do Ii remove the grey page numbers in a work sheet
how do Ii remove the grey page numbers in a work sheet Try going to the View menu and unchecking Page Break Preview On Wed, 2 Feb 2005 11:01:08 -0800, "parker1230" <parker1230@discussions.microsoft.com> wrote: >how do Ii remove the grey page numbers in a work sheet You may be in page break preview mode. Go to "View" and select "normal" Regards Bill K "parker1230" <parker1230@discussions.microsoft.com> wrote in message news:5A65FC73-CAA0-428D-8ECD-0C2A2E15B799@microsoft.com... > how do Ii remove the grey page numbers in a work she...

100% CPU by using filter in Excel
An employee tried to use filter in one special table and the PC did nee 100% CPU time and work more than 15 min. I checked it with other PC. The table is working and PC use only abou 50% CPU and need about 3 min to finish the job. I installed the last SP3 for office XP and it is not solved th problem. The employee has German OS and english office. Has anyone an idea? Please help -- languate ----------------------------------------------------------------------- languatec's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2654 View this thread: http://www.excelforum...

show columns on other worksheet without using formulas
Hi, I have 1 worksheet containing lot's records. Just like in access, each line is 1 record, and each column contains data. ex: WORKSHEET 1: name title address city 1 dfjw kjhk kjhkj kjhk 2 lmkj lkjlk lkjkuf guyg 3 drdtg xcx yjutuy hgyy Now I want to have a selection of columns on worksheet 2: ex, only name and title: WORKSHEET 2: name title 1 dfjw kjhk 2 lmkj lkjlk 3 drdtg xcx I will only add/modify rows in worksheet 1. And I want that this is filled automaticaly in worksheet...

help with the syntax for using range name in a formula?
I have --------=3D+AVERAGE(SMALL(B7:B19,{1,2,3}))-------------. I want to replace B7:B19 with =93Myrange=94 but I can=92t seem to get the syntax right. excel says error in formula. Thks in advance for any help BRC Hi =AVERAGE(SMALL(Myrange,{1,2,3})) have you created Myrange? have you spelt it correctly? -- Regards Roger Govier "BRC" <brc1051-googrps@yahoo.com> wrote in message news:d0e09817-22dc-4c36-b60d-67a397067441@h9g2000yqa.googlegroups.com... > I have --------=+AVERAGE(SMALL(B7:B19,{1,2,3}))-------------. I want > to replace B7:B19 with �Myra...

German government warns against using MS Explorer
Now this must be the news of 2010 After nearly 10 years of unlimited patches, hotfixes and service Packs, IE is still a weak link in recent attacks on Google's systems. Either M$ is now threatened by Googles rise to prominence or IE is completely rubbish. Either way we should start taking instructions from the German government if this article is anything to go by. <http://news.bbc.co.uk/1/hi/technology/8463516.stm> Is google's search engine more powerful than M$ Bing? > Now this must be the news of 2010 > and 2011....and 2012.... IE problem...

I use client ID #s. Some begin with 0. 0 needs to show
I am creating a client sheet. Some of the Client ID #s begin with Zero. How can I get the Zero to show? hi, you can format the cells as a text, hope this helps Regards from Brazil Marcelo "rmingle" escreveu: > I am creating a client sheet. Some of the Client ID #s begin with Zero. How > can I get the Zero to show? You can also use a custom format: Suppose you ID numbers have 7 character including the leading 0 then do this: Select the cell(s) Press Ctrl-1 In the numbers tab select custom. In the box "type" enter 7 zero's HTH "Marcelo" wr...

Margin Trouble with Custom Page Size
When I try to print in Publisher using a custom page size, printer or Publisher adds approx 1.5" to the top of my page margin, no matter what I do. Checked the printer settings in WordPad, all looks OK. Issue does not occur when printing on 8.5X11 page, nor does it occur in MS Word. I don't have any extra margin set in Master Page...have tried everything I can think of. Under deadline to print invitations and getting desperate...help! Thanks. How are you setting up your printer? Are you saving the custom setting? Are you setting up your printer first? What model is your pr...

Creating a Report using Tables (that have no relationships)
Im looking to create an invoice report that uses data from three different tables that are created dynamically by a query. The data for these will change but I would like to simply pull the data from these tables to create a report. The tables have the following information: 1. Company Info (name, address) 2. Customer Info (address, name, etc) 3. Customer Order (products, price, other info) 4. Invoice Info (ID, GST #, etc) I realize I could have created a table with relationships but the data above is dynamic as there are 4 different companies and based upon user inp...

Macro to Protect workbook using a password #2
I know this would be a little unorthodox, but I currently have a macro that will unprotect a workbook including a password. The line is as follows: ActiveWorkbook.Unprotect (password) I also want a macro that will do just the opposite, including the password. Is this possible? I've tried the following with no luck. ActiveWorkbook.Protect (password), Structure:=True, Windows:=True You got two replies when to your identical post on Tuesday. If they weren't suitable, please explain why not. If you didn't see them, you can always see your posts and any replies using the Go...

connecting to data access page with filter criteria
I have an access database that I connect to from a GIS application (ArcView) using VBscript. I need to port my GIS project to the free viewer (ArcReader) which does not support VBscript but does support hyperlinking to a URL based on a value supplied by an underlying record. In my current project I can send filter critera to open a particular database, form and record. Would it be possible to do the same using data access pages or would I need to create a separate page for each record I want linked? ...

Money 2005 Bug: Portfolio toolbar button loads blank page titled Portfolio Manager
Problem Description: Clicking on the Portfolio toolbar button loads a blank page that's titled Portfolio Manager. That's it! I can't see any of my open positions, etc... using this toolbar button. Frequency of problem: Always Happens Operating system / version: Microsoft Windows XP Professional - 5.1.2600 Computer manufacturer and model: Dell Computer Corporation, Dimension 8200 Processor model and speed: I586IV, 1994 MHz Memory (RAM): 523.276 MB The only input I can offer is that I have the same problem on one computer, but it works fine on the other. I converted from 2004 Delu...

Using Query by typing " SELECT......"
Hello, When I saw on the addresss sample database, the form Household is uing query by just mentioning SELECT...... My question is how can type SELECT then prompt the table to us. I normally use grid query, what is the difference using grid query of SQL Query ( is it SQL that using SELECT....?) Many thanks for any idea provided -- H. Frank Situmorang The RecordSource property of a form can accept: - a table name - a query name - a SQL statement. You can change the RecordSource property of the form programmatically. For example, if the form currently has a RecordSource of: SELECT ...

Using <Ctrl>-Click to open files
When using <Ctrl>-Click to open multiple files from the File/Open dialog in Excel 2003, only the first file will appear on the taskbar. A combo-box type Taskbar selector for multiple Excel files does *not* appear. Also, only the first file appears on the <Alt>-<Tab> menu. However, all files appear in the Excel Window menu. The problem also occurs when using <Ctrl>-Click/Right- Click/Open to open multiple files from Windows Explorer or My Computer. The problem does not occur when opening the files individually. Is this a known problem? Is there a fix? Thanks! ...

Excel page format changes
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Hello, <br><br>My client creates spreadsheets for her boss. She pushes the boundaries to get things to fit on the screen. <br> Uses A4, margins at 1.5cms and scales to 90%. <br><br>When her boss receives it by email the margins go to 2.5cms, scales to 100%. They have the same versions 12.2.4 and Leopard. They are just about to be upgraded to Snow Leopard. Any idea why this could be happening? Thanks. ...

Cell identity when printing comments on separate page
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel When printing comments at end of page, it identifies the cell by letters and numbers. (i.e. Cell: AA33) Afterward the comment is shown for that cell. <br><br>Question: Instead of the cell identity being shown this way, is it possible ithe cell can also be identified by its X axis header for that column with the y access header for that Row. <br><br>Thank for your assistance. <br><br>Carl Sorry Carl, but I'm not clear on what you're asking for... In 'MySpeak' ...

Howto draw CImageList using alpha channel (repost)
I am desperately trying to draw images from an imagelist to the screen, using the alpha channel to blend nicely into the background. Alas, I give up, I am totally confused with all the flags and options, having tried out probably all the possible combinations except the one that works :-) Here's my (abbreviated) code: --------- CImageList myImageList; myImageList.Create (24,24,ILC_COLOR32,0,1); CBitmap myBitmap; myBitmap.LoadBitmap (IDB_MYBITMAP); myImageList.Add (&myBitmap, RGB(255,0,255)); CDC dc; dc.Attach (lpDrawItemStruct->hDC); // this comes from the caller myImageLis...

Use Outlook Client when domain user name different with email acco
Hello, I have a question about using Outlook Client. If the domain user login name is different with email account which belong to a same person, is it possible to install / login with the Outlook client? e.g domain user : degdom\apple email account: applewatson@deg.com One of my client is facing in this situation. I just want to have some preparation before install Outlook Client for him. Thanks for any help! Hi Huimc, It shouldn't be a problem if the AD user is the same used to start Outlook and connect to CRM. You may want to check the email adress in CRM if the ema...

How to use ampersand in footers like CS&S
I am defining my project plan and I have to place proprietary footers on the document. When I use the ampersand in the footer it displays the time and not the acronym for my company such as CS&S. It will show CS&[Time] and then display the time on my printouts. If I use a double ampersand it does the same thing. How can I use the ampersand as needed in my company Acronym CS&S? You could always paste the company logo as a graphic into the footer? Maybe use it as a field somewhere and add the field to your footer. "Sue" wrote: > I am defining my ...

Using mail merge for nametags, how'd you get 8 diff. on each pg?
How do I print off a different name on each name tag in order to print them out a page at a time? I entered the names in mail merge and it will print them, just a whole page of each. Thanks "juliehrbacek" wrote: > How do I print off a different name on each name tag in order to print them > out a page at a time? I entered the names in mail merge and it will print > them, just a whole page of each. > > Thanks This is the same question that has brought me here. I've been trying to figure it out for over 2 hours now and am about ready to pull my hair ou...

PowerPoint crashing while using Slide Library
What: I wanted a way to have many individuals owning and updating content, as well as one place to display all of the content so I decided a PowerPoint presentation built off a slide library would be an effective way to facilitate this. Whats the issue: I wanted one slide to be the overview slide showing all the content within, and links to the individual slides with the actual content. Creating these links and hitting save crashes powerpoint. (Note: I tried the same steps with a PowerPoint presentation that was not created from a slide library and it did not crash.) He...

Outlook 2000 unable to use apply
Recently, our Exchange Server 5.5 crashed. We restored all the mailboxes using exmerge. The only problem we are running into now is a few clients cannot apply any changes they make. The apply button is gray. The user in question has local admin rights. Help! ...

Office 2007 non-commercial use + Code 78F when updating
Hi All, Have a couple questions relating a Vista/Office 2007. We bought a sony vaio laptop that came pre-intalled with a trial license of office 2007. I un-installed Office completely and install a fresh copy of our partner license copy of office 2007, but when loading any office application now its shows 'Microsoft Outlook non-commercial use' and same for word,excel, etc. Anyone have any idea why this is? Second question is relating to windows updates in Vista; I get an error Code 78F when trying to install any update, and the soultions i try doesnt seem to resolve this issue....

Using VBA to Print PDF Files
Hi: My customer has PDF spec sheets for their inventory items. When a pick ticket is printed, they wish to print the PDF spec sheets for each item on the pick tickets. I am very comfortable with the report event structure and know exactly how to get to the PDF files using VBA, but I am having a problem getting the docs printed. I've taken two approaches: 1. Drop ACROPDF.dll onto a User Form in the VBA project. To do this, I created a procedure on the form as shown: Public Sub PrintPDF(FileName As String) AcroPDF1.LoadFile (FileName) AcroPDF1.printAll PDFPrinter.Hide End Sub T...