Vous êtes sur la page 1sur 33

# 5 . Y o u a r e i m p l e m e n t i n g a n A S P . N E T W e b s i t e .

T h e s i t e

a l l o w s u s e r s t o e x p l i c i t l y c h o o s e t h e d i s p l a y l a n g u a g

e f o r t h e s i t e ' s W e b p a g e s . Y o u c r e a t e a W e b p a g e t h a t c o n

t a i n s a D r o p D o w n L i s t n a m e d d d l L a n g u a g e , a s s h o w n i n t h

e f o l l o w i n g c o d e s e g m e n t .

<asp: DropD ownLi st ID="d dlLan guage " runat ="ser ver" AutoP ostBa ck="T rue" Clien tIDMo de="S tatic " OnSel ected

Index Chang ed="S elect edLan guage Chang ed"> <asp: ListI tem Value ="en" >Engl ish</ asp:L istIt em> <asp: ListI tem Value ="es" >Span ish</ asp:L istIt em> <asp: ListI tem Value ="fr" >Fren ch</a sp:Li stIte m> <asp: ListI tem Value ="de" >Germ an</a sp:Li stIte m>

</asp :Drop DownL ist>

T h e s i t e c o n t a i n s l o c a l i z e d r e s o u r c e s f o r a l l p

a g e c o n t e n t t h a t m u s t b e t r a n s l a t e d i n t o t h e l a n g u a g e t

h a t i s s e l e c t e d b y t h e u s e r . Y o u n e e d t o a d d c o d e t o e n s u r

e t h a t t h e p a g e d i s p l a y s c o n t e n t i n t h e s e l e c t e d l a n g u a

g e i f t h e u s e r s e l e c t s a l a n g u a g e i n t h e d r o p d o w n l i s t .

W h i c h c o d e s e g m e n t s h o u l d y o u u s e ? # A .

protected void SelectedLanguageChanged(object sender, EventArgs e) { Page.UICulture = ddlLanguage.SelectedValue; }

# B .

protected override void InitializeCulture() {

Page.UICulture = Request.Form["ddlLanguage"]; }

# C .

protected void Page_Load(object sender, EventArgs e) { Page.Culture = Request.Form["ddlLanguage"]; }

# D .

protected override void InitializeCulture() { Page.Culture = ddlLanguage.SelectedValue; }

Answer: B Wrong answer? Show/hide vote pane Vote Answer #A. #B. #C. #D. Your browser will NOT be Winner no yes no no # of Votes 0 10 0 0

redirected. Show comments for this question (0) Add comments Link to this question

# 6 . Y o u a r e i m p l e m e n t i n g a n A S P . N E T

a p p l i c a t i o n t h a t i n c l u d e s t h e f o l l o w i n g r e q u i r e m e n t

s . R e t r i e v e t h e n u m b e r o f a c t i v e b u g s f r o m t h e c a c h e , i

f t h e n u m b e r i s p r e s e n t . I f t h e n u m b e r i s n o t f o u n d i n t h e

c a c h e , c a l l a m e t h o d n a m e d G e t A c t i v e B u g s , a n d s a v e t h e

r e s u l t u n d e r t h e A c t i v e B u g s c a c h e k e y . E n s u r e t h a t c a c

h e d d a t a e x p i r e s a f t e r 3 0 s e c o n d s . Y o u n e e d t o a d d c o d e t

o f u l f i l l t h e r e q u i r e m e n t s . W h i c h c o d e s e g m e n t s h o u l d

y o u a d d ? # A .

int numOfActiveBugs = (int)Cache["ActiveBugs"]; if (!numOfActiveBugs.HasValue) { int result = GetActiveBugs(); Cache.Insert("ActiveBugs", result, null, DateTime.Now.AddSeconds(30), Cache.NoSlidingExpiration); numOfActiveBugs = result; } ActiveBugs = numOfActiveBugs.Value;

# B .

int numOfActiveBugs = (int) Cache.Get("ActiveBugs"); if (numOfActiveBugs != 0) { int result = GetActiveBugs(); Cache.Insert("ActiveBugs", result, null,

DateTime.Now.AddSeconds(30), Cache.NoSlidingExpiration); numOfActiveBugs = result; } ActiveBugs = numOfActiveBugs;

# C .

int numOfActiveBugs = 0; if (Cache["ActiveBugs"] == null) { int result = GetActiveBugs(); Cache.Add("ActiveBugs", result, null, DateTime.Now.AddSeconds(30), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); numOfActiveBugs = result; } ActiveBugs = numOfActiveBugs;

# D .

int numOfActiveBugs = (int?)Cache["ActiveBugs"]; if (!numOfActiveBugs.HasValue) { int result = GetActiveBugs();

Cache.Insert("ActiveBugs", result, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(30)); numOfActiveBugs = result; } ActiveBugs = numOfActiveBugs.Value;

Answer: A Wrong answer? Show/hide vote pane Vote Answer #A. #B. #C. #D. Your browser will NOT be redirected. Show comments for this question (0) Add comments Link to this question Winner yes no no no # of Votes 12 1 1 0

7 . Y o u a r e i m p l e m e n t i n g a m e t h o d i n a n A S P . N E T a p p l i c a

t i o n t h a t i n c l u d e s t h e f o l l o w i n g r e q u i r e m e n t s . S t o r e

t h e n u m b e r o f a c t i v e b u g s i n t h e c a c h e . T h e v a l u e s h o u l d

r e m a i n i n t h e c a c h e w h e n t h e r e a r e c a l l s m o r e o f t e n t h a n

e v e r y 1 5 s e c o n d s . T h e v a l u e s h o u l d b e r e m o v e d f r o m t h e

c a c h e a f t e r 6 0 s e c o n d s . Y o u n e e d t o a d d c o d e t o m e e t t h e r

e q u i r e m e n t s . W h i c h c o d e s e g m e n t s h o u l d y o u a d d ? # A .

Cache.Insert("ActiveBugs", result, null,

DateTime.Now.AddSeconds(60), TimeSpan.FromSeconds(15));

# B .

Cache.Insert("Trigger", DateTime.Now, null, DateTime.Now.AddSeconds(60), Cache.NoSlidingExpiration); CacheDependency cd = new CacheDependency(null, new string[] { "Trigger" }); Cache.Insert("ActiveBugs", result, cd, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(15));

# C .

Cache.Insert("ActiveBugs", result, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(15)); CacheDependency cd = new CacheDependency(null, new string[] { "ActiveBugs" }); Cache.Insert("Trigger", DateTime.Now, cd, DateTime.Now.AddSeconds(60), Cache.NoSlidingExpiration);

# D .

CacheDependency cd = new CacheDependency(null, new string[] { "Trigger" }); Cache.Insert("Trigger", DateTime.Now, null, DateTime.Now.AddSeconds(60), Cache.NoSlidingExpiration);

Cache.Insert("ActiveBugs", result, cd, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(15)); NV0XE-Y7GZZ

Answer: B Wrong answer? Show/hide vote pane Vote Answer #A. #B. #C. #D. Your browser will NOT be redirected. Show comments for this question (0) Add comments Link to this question Winner no yes no no # of Votes 0 10 0 0

Vous aimerez peut-être aussi