Microsoft Content Management Server - Code suggestion for Book

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > May 2005 > Code suggestion for Book





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Code suggestion for Book
GoldUser

2005-05-25, 6:00 pm


Just an FYI/Tip.

In the book Building Websites with Microsoft Content Manager, on page 294...

there is a block of code at the top of the page for get information on a
placeholder. One of the lines is:
=======
if(r!=null)
=======
This works fine if the (url.Split) line (4 lines of code above) returned a
string with the proper sections (i.e. GUID). Unfortunately, on testing, I
have come across situations where the string returned hasn't been null, but
was an empty string (i.e. ""), so...running the split common on a string with
no characters will return nothing and so the rest of the code will crash the
page. To solve this, I added to the line as follows:
========
if(r!=null && researchPaper.Url!="")
========

Hope this helps others.

Dave

Mei Ying [MVP]

2005-05-25, 6:00 pm

Hi

That's a good tip!

Actually, if you skip a few pages down to page 299, the concept of detecting
when an attachment placeholder is empty is discussed.

regards
Mei Ying
---
Blog: http://meiyinglim.blogspot.com
Book: http://www.packtpub.com/book/mcms
Contact: meiyinglim@hotmail.com
---

"GoldUser" <GoldUser@discussions.microsoft.com> wrote in message
news:20C4634A-32F0-4D55-8AA1-8095B550ACA9@microsoft.com...
>
> Just an FYI/Tip.
>
> In the book Building Websites with Microsoft Content Manager, on page

294...
>
> there is a block of code at the top of the page for get information on a
> placeholder. One of the lines is:
> =======
> if(r!=null)
> =======
> This works fine if the (url.Split) line (4 lines of code above) returned a
> string with the proper sections (i.e. GUID). Unfortunately, on testing, I
> have come across situations where the string returned hasn't been null,

but
> was an empty string (i.e. ""), so...running the split common on a string

with
> no characters will return nothing and so the rest of the code will crash

the
> page. To solve this, I added to the line as follows:
> ========
> if(r!=null && researchPaper.Url!="")
> ========
>
> Hope this helps others.
>
> Dave
>



GoldUser

2005-05-25, 6:00 pm


Mei Ying,

Thank you for the heads-up on page 299. I am currently on 297. I go very
slowly and methodically when doing lessons. I also expand on each idea (like
when you have us do 4 properties of a class, I do them all just to text my
skills and see what the results are).

Question: A few Questions back on this board, (about 2 pages back) I left a
message called Errata, Errata, who's got the Errata..about another possible
errata I think I found. Can you let me know if I did or not?...Thank you in
advance.

Dave


GoldUser

2005-05-25, 6:00 pm


Mei Ying,

I got to page 299 regarding detecting empty holders.

Unfortunately, those instructions only deal with display type situations,
not logic situations. In the case of page 294, the logic would not be able
to handle the empty string (i.e. the split, etc.. lines) and would crash the
page with a CMS error page before any displaying could happen.

Except for the line of code I sent at the beginning of this discussion:
.....if(r!=null && researchPaper.Url!="")

I could only think of using your page 299-300 code like the line above but
like..(not the NOT exclamation I put before the
IsAttachmentPlaceholderEmpty...
........if(r!=null && !IsAttachmentPlaceholderEmpty(researchPa
per))

Thoughts? And thank you again for your time.

Dave


Mei Ying (MVP)

2005-05-26, 2:52 am

Hi Dave

You are right, the context in which it was written was about how to
hide/show the display text. But underlying that is the idea behind detecting
when the attachment placeholder is empty.

Your suggestion does the right thing (it's definitely a great tip!). Here's
another way to do it: Instead of checking for the empty placeholder in the
if(r!=null) statement, do it before splitting the string. Something like this:

if(IsAttachmentPlaceholderEmpty(research
Paper))
{
//Grab that GUID
. . . code continues . . .
if(r!=null)
{
. . . code continues . . .
}
}

In an actual implementation, if you need to do this often, it will probably
be a good idea to encapsulate the entire code snippet into a method that
accepts the URL/placeholder as an input parameter.

What do you think?

regards
Mei Ying
---
Blog: http://meiyinglim.blogspot.com
Book: http://www.packtpub.com/book/mcms
Contact: meiyinglim@hotmail.com
---


"GoldUser" wrote:

>
> Mei Ying,
>
> I got to page 299 regarding detecting empty holders.
>
> Unfortunately, those instructions only deal with display type situations,
> not logic situations. In the case of page 294, the logic would not be able
> to handle the empty string (i.e. the split, etc.. lines) and would crash the
> page with a CMS error page before any displaying could happen.
>
> Except for the line of code I sent at the beginning of this discussion:
> ....if(r!=null && researchPaper.Url!="")
>
> I could only think of using your page 299-300 code like the line above but
> like..(not the NOT exclamation I put before the
> IsAttachmentPlaceholderEmpty...
> .......if(r!=null && !IsAttachmentPlaceholderEmpty(researchPa
per))
>
> Thoughts? And thank you again for your time.
>
> Dave
>
>

Mei Ying [MVP]

2005-05-26, 2:52 am

Hi Dave

Oops! I missed that post...you know what, you've spotted one on that page!
The text should either say:

1. The Button ID = btnGetPlaceholderContent and the name of the onclick
event handler = btnGetPlaceholderContent_Click(), or

2. The Button ID = btnGetFactSheetContent and the name of the onclick event
handler = btnGetFactSheetContent_Click()

Great job! Thanks for highlighting all the erratas!

If you have any queries, fill free to contact us (you've got our emails) :-)

--
regards
Mei Ying
---
Blog: http://meiyinglim.blogspot.com
Book: http://www.packtpub.com/book/mcms
Contact: meiyinglim@hotmail.com
---


"GoldUser" wrote:

>
> Mei Ying,
>
> Thank you for the heads-up on page 299. I am currently on 297. I go very
> slowly and methodically when doing lessons. I also expand on each idea (like
> when you have us do 4 properties of a class, I do them all just to text my
> skills and see what the results are).
>
> Question: A few Questions back on this board, (about 2 pages back) I left a
> message called Errata, Errata, who's got the Errata..about another possible
> errata I think I found. Can you let me know if I did or not?...Thank you in
> advance.
>
> Dave
>
>

GoldUser

2005-05-26, 5:55 pm


Mei Ying,

Thank you for both of the replies.

*smile*

Dave


GoldUser

2005-05-26, 5:55 pm


A note on these erratas. It would be nice if Packt publishing would at
least send an e-mail to a person submitting an errata, they don't even have
to say thank you, but at least letting the submitter know that they received
and whether it was right/wrong, etc.. Instead of someone having to go to a
discussion forum hoping an author/someone will agree/disagree. Of course I
guess most readers don't take the time/effort to help out either..*smile*


GoldUser

2005-05-26, 5:55 pm


well, there ya go, Murphy's law kicks me in the butt.

Right after I sent a message about not hearing from Packt about the erratas,
I get a message from Packt about the erratas.

Dang Murphy's law!

*smile*


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com