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
4091 Views

Similar Articles

[PageSpeed] 20

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:

Opening File using default viewer
Hello, how would I go about opening a file using the default viewer, so for example, if the file is a txt file, then notepad would open it. Or if it is an XML file, then maybe firefox woulld open it. I was hoping to use a CButton and if the user clicks on it, then it would grab the path specified and open the file with the corresponding viewer. thanks. Jon wrote: > Hello, how would I go about opening a file using the default viewer, so > for example, if the file is a txt file, then notepad would open it. Or > if it is an XML file, then maybe firefox woulld open it. > > ...

Use of Pop3 accounts for external email
We've been using a pop3/smtp account to recieve our external email. I've heard that using those is a bad idea for a buisness. I don't understand it that much and wondering what are the issues with pop3 and what is an alternative to recieve external mail if not using a pop3 account. We have Exchange 2003. The issue is the company can't archive all user's mail. You know, company's email is representing the company, so the company should keep it as archives. With POP3 email will be moved from server to the client. Instead, you can use IMAP, Exchange Server, or ...

Outlook 2000 Change Startup Page
Have a problem with Outlook 2000, think it happened when I ran repair. Now everytime I open Outlook the "Outlook Today" page opens, then have to select the inbox folde to view my mail. Used to always open on the Inbox Folder. What have I done, is there a way to restore this. You’ve landed in a Macintosh group, sorry. Try asking your question on the general Office newsgroups. Start here: http://www.microsoft.com/office/community/en-us/default.mspx DooBee wrote: > Have a problem with Outlook 2000, think it happened when I ran repair. Now > everytime I open Outlook the...

Trouble with hyhens within text when using LOOKUP
I have two columns, each containing a list of part numbers. Some of the part numbers contain hyphens. I am using LOOKUP and/or VLOOKUP to determine if the value in one column exists in the other. This works great on non-hyphenated part numbers. However, it will not find or return the hyphenated part numbers from the specified arrays. As a test, I did a quick if statement to compare the instances of identical hyphenated values that exist in both columns. Those statements did not have a problem with the hyphens. Can anyone offer any help? If hyphens cannot be used in conjunction with the ...

Using formulas to filter
Is there a way to filter a list by formulas the same way the Data->Filter option works? I'd like to take the matrix: Col A Col B Col C Col D Col E ===== ===== ===== ===== ===== Smith 30 $104.2 Yes 52 Jones 31 $155.3 No 51 Jones 31 $422.2 Yes 49 Freer 31 $424.3 Yes 42 Waylan 30 $322.5 No 50 Smith 31 $288.3 Yes 49 etc. And, using a formula, filter on Col B = 31 to produce: Col AA Col AB ...

RE: Use that security update
--dedtgpho Content-Type: multipart/related; boundary="yzkfzsfqtv"; type="multipart/alternative" --yzkfzsfqtv Content-Type: multipart/alternative; boundary="qeviqcxczwaquy" --qeviqcxczwaquy Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Microsoft Consumer this is the latest version of security update, the "October 2003, Cumulative Patch" update which eliminates all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express as well as three newly discovered vulnerabilities. Install now to hel...

Page setup / page / size??????
Hi, When you are in design view and you click on 'Page setup / page / size' are the options listed based on the printer you have installed or are they options that Access knows? If I select any of the options listed will they work on any printer? Thanks, Phil They are printer-specific. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Phillip" <Phillip@discussions.microsoft.com> wrote in message news:92C07A38-11FE-4620-97C...

Has anyone used the Remove MO Utility?
I have a closed Quick MO that did not process properly somehow. The MO is flagged as closed, but sime items were not issued and are stuck in WIP. I ran the Tools > Utilities > Manufacturing > Remove MO process in a test database. It removed the MO and the items re no longer hung up in WIP. Has anyone else ever executed this process? Are there any gotcha's I need to be aware of? Many Thanks. Jim Hi Jim, I too have used this in a development/test environment and have not encountered any problems. -Mike -- Micheal LoPatriello Coordinator, Luna Development mlopat@lu...

How to use CxImage?
Hi I want to display a jpeg picture by using CxImage but I am new to visual c++ so I couldn't understand how to use this class in my project.Is there someone who have used this class and can you help me about using it? Thanks On Jul 3, 7:12 am, ibrahim <ibra...@discussions.microsoft.com> wrote: > Hi > I want to display a jpeg picture by using CxImage but I am new to visual c++ > so I couldn't understand how to use this class in my project.Is there someone > who have used this class and can you help me about using it? > Thanks Its all here: http://www.codeproj...

How can I send e-mail as a web page
Hi! I am in the process of creating "Newsletters", and it will be a web page/html file. Is there a way I can send this to recipients so that it will be displayed as a web page in their e-mail? Outlook express had a shortcut for this, but I cannot seem to find this function in Outlook 2003. Thanks in advance : ) You either send from within the program you created the html webpage or from within Outlook use; Insert-> File...-> select HTML file-> press little down arrow on Insert-> choose Insert as Text -- Roady [MVP] www.sparnaaij.net Microsoft Office and Microsoft Off...

Name Range with using Data Form
I first created a variable with A1:D1, four columns with named variable Data. How to expand this Data range to A1:D2 after using the DataForm to add one row data in the worksheet?? The same, the Data range should be A1:D3 when adding one more data row... million thanks Hi use the following formula in the name definition dialog =OFFSET($A$1:$D$1,0,0,COUNTA($A:$A)) >-----Original Message----- >I first created a variable with A1:D1, four columns with named variable >Data. How to expand this Data range to A1:D2 after using the DataForm to add >one row data in the worksheet?? The...

Using Outlook to access and compile information in calendar
I want to create an application that will compile schedule information from Excel worksheets or an Access database and display them in a calendar type format. I know this type of application can be built using PivotTables in Excel, or forms in Access, but I was wondering if I could use the calendar in Outlook to display the information rather than creating PivotTables or custom forms which would wind up looking something like a calendar anyway. Before I start the job I'd like to know if I can work Outlook into the equation or if I really have to build it from scratch. Thanks, JEM ...

Using cell text in a formula
I am trying to use derived cell references in a VLOOKUP formula to matc data in several tables. For example, A1 contains the cell reference fo the top left of my array (A3) whilst cell A2 contains the cel reference for the bottom right of my array (D14). The array I' checking against starts in column E3. However, when I use the formula =VLOOKUP(E3,A1:A2,4,FALSE) I get a #N/ error. I need to use the cell references in each VLOOKUP as the arra sizes may vary in each case. (PS, I've used =INDIRECT(ADDRESS(A1,A2) to derive the cell references. Ji -- Message posted from http://www.Excel...

Using two conditions in a formula
How do I write the following formula: I am in cell I6 If g6 AND h6 is blank, then blank, else I5 minus g6 plus h -- Richard Pit ----------------------------------------------------------------------- Richard Pitt's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1533 View this thread: http://www.excelforum.com/showthread.php?threadid=27042 Richard, In cell I6, enter the formula: =IF(AND(G6="",H6=""),"",I5-G6-H6) Though you don't check for case when G6 is blank and H6 isn't, etc. HTH, Bernie MS Excel MVP "Richard ...

How to use MSExcel to plot Column A against Col B?
I want to plot col A (x axis) against col B ( y axis). I cant seem to do it. Can anyone here please give me step by step primer. Thanks in advance. All I get is the graph of (1,2,............n) (x axis) against the n values of either col A or B. i.e 2 graphs instead of one. (In the old Lotus this was so simple: select the column for the X axis and then select the col for the Y and press enter, and you'd get the chart) Why is it so diff in Excel? Select the entire range you want to graph such as a2:b44>insert>chart>>>> -- Don Guillett SalesAid Software dguillett1@au...

Using CMFCToolBar and CMFCMenuBar?
After initial frustrations indicated by recent messages, I am now getting on with these classes relatively cordially. The user of my program can add or remove buttons to/from the CMFCToolBar(s), and menu items to/from the CMFCMenuBar - all beautifully customisable. The program knows about the available commands and they can be added to any toolbar or menu. And new custom tool bars can be added by the user. It's all fiendishly clever. However: my questions (today) are as follows: 1. The MFC Customise dialogue, from which one can drag commands to toolbars and menus,...

buy from this E-hermesol company is fast only used my 5days
I would like to introduce you a very good company which I knew. Their company homepage is www.ehermesol.com. They can offer you all kinds of electronical products which you need, such as motorcycles, laptops, mobile phones, digial cameras, TV LCD ,x box, ps3, gps, MP3/4, etc. Please take some time to have a look at it, there must be something you 'd like to purchase. Their contact email: ehermesol@188.com MSN: ehermesol@hotmail.com Hope you have a good mood in shopping from their company! Regards ...

Text box jumps to left of page
Word 2004 (I am relatively new to Word and am delighted to find a forum specifically for the Mac version. There are a number of unresolved, niggling issues I can live however they slow the workflow. I am eager to learn.) In the recent past, I manually converted 12,000+ recipes from WordPerfect 7 to Word. Since Word 2004 does not have a filter for the old files, the conversion was done on the Windows side of my Mac in Word2003. Those files _usually_ open without protest also in 2004. One annoyance regards text boxes. When text was highlighted and a text box was requested for it in...

Excel
Can you have a combination of both portrait and landscape pages in worksheet ? I suppose that the page setup setting applies uniformly fo all pages in the worksheet ? How you could get around this ? Than you. CJ -- Message posted from http://www.ExcelForum.com Hi you're right: You can have only ONE orientation per worksheet at the same time. One workaround for printing: - tsart recording a macro - set the page orientation for the first part of your sheet - print the desired pages - change the page orientation - print the remaining pages Now use this recorded macro for printing >...

endnotes on new page
Is there a way to put all the endnotes together on a new page? I've tried inserting a page break in the endnote separator and tried setting the endnote separator to start on a new page, but those methods didn't work. Thanks. -- ~ Janet Insert a page break before the endnote separator. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Janet S" <JanetS@discussions.microsoft.com> wrote in message news:C...

How did you add text into publisher, without using boxes?
how do you add text to publisher without using text boxes I suppose you could create your text as an image and insert the image into your publisher file. -- Don Vancouver, USA "Calvin Scott" <Calvin Scott@discussions.microsoft.com> wrote in message news:64D23D52-138D-47B4-B265-4A41BF14BF55@microsoft.com... > how do you add text to publisher without using text boxes Calvin Scott <Calvin Scott@discussions.microsoft.com> was very recently heard to utter: > how do you add text to publisher without using text boxes You don't. Text in Publisher has to e...

I want to design both side of a post card using publisher 03
I have go side one completed. How do I do the other side??? Insert Page -- Don Vancouver, USA "bettboop" <bettboop@discussions.microsoft.com> wrote in message news:68D78C55-BB03-44EC-97AF-D8FBA74FB95C@microsoft.com... >I have go side one completed. How do I do the other side??? ...

Using Outlook over a Network
Hi, I would like to know what software I need to allow multiple users to access one MS Outlook Calendar. The computers currently have Outlook 2000 and I would like the users to be able to edit one central calendar simultaneously, directly in the calendar (ie. not requiring users to send emails etc.) What sofware beyond Outlook 2000 do I need and is there any info on how this is done? Thanks Adrian Check out http://www.slipstick.com/outlook/share.htm -- PATRICK REED [Outlook - MVP]~~~~~~ -Microsoft Certified Professional (MCP) -Have you checked http://www.slipstick.com? -Plea...

how to use 2007 styles in Word 2003
hi everyone, we have Word 2003 but we really like the Styles that come with Word 2007. Is it possible to export these Styles and use it in Word 2003? And if yes, how can i do that. In Word 2007, click the Home tab of the ribbon. In the Styles group, click Change Styles | Style Set | Word 2003. To make this choice the default, click Change Styles again, and then click Set as Default. If/when you are prompted to save the changes to your template, choose to do so. -- Stefan Blom Microsoft Word MVP "skoub" <skoub@discussions.microsoft.com> wrote in messa...

How is the ease of use for salespeople compared to other tools?
With the goal of keeping it simple, it seems like there are a lot of steps, drop downs, etc. that slow up the inputting of information. Is there customization that is needed to speed this up would you think? is this a crm 1.2 or 3.0 question. Microsoft made a big effort to reduce the time to navigate around and input data in crm 3.0. you always have the option of building custom forms to allow you to enter data quickly then have these populate crm ========================= John O'Donnell Microsoft CRM MVP http://www.microsoft.com/businesssolutions/crm/community/microsoft_crm_co...