Skip to main content
deleted 1 character in body
Source Link
Velmurugan
  • 8.2k
  • 2
  • 15
  • 27

Hello Friends I am trying to check or print the component values after the saving event is triggered.

I want to check on each component save. User added the www.blahblh.com URL or not then take action as per URL I am getting.

    public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
            {
                   Component comp = subject;
                    
                    string str = comp.Content.Value; // in str values getting empty
            }

updated code.

    public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
    {
        ItemFields fields = new ItemFields(component.Content, component.Schema);
        foreach (var items in fields)
        {
            if(items.ToString().Contains("www.blahblah.com"))
            {
                //throw pop up exception 
            }
            else{
                //save logic
            }
        }
    }

Using this code iI am able to check whether the component field containcontains the urlURL or not. Bur problem is its workworks only for textfieldthe text fields. How to read the data if the component field containcontains EmbeddedSchemaField,ComponentLinkField ComponentLinkField. Any

Any solution to catch this all filed in parent node level and read as string  ?

Thanks in advance :)

Hello Friends I am trying to check or print the component values after the saving event is triggered.

I want to check on each component save. User added the www.blahblh.com URL or not then take action as per URL I am getting.

    public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
            {
                   Component comp = subject;
                    
                    string str = comp.Content.Value; // in str values getting empty
            }

updated code.

    public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
    {
        ItemFields fields = new ItemFields(component.Content, component.Schema);
        foreach (var items in fields)
        {
            if(items.ToString().Contains("www.blahblah.com"))
            {
                //throw pop up exception 
            }
            else{
                //save logic
            }
        }
    }

Using this code i am able to check the component field contain the url or not. Bur problem is its work only for textfield. How to read the data if component field contain EmbeddedSchemaField,ComponentLinkField. Any solution to catch this all filed in parent node level and read as string  ?

Thanks in advance :)

Hello Friends I am trying to check or print the component values after the saving event is triggered.

I want to check on each component save. User added the www.blahblh.com URL or not then take action as per URL I am getting.

    public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
            {
                   Component comp = subject;
                    
                    string str = comp.Content.Value; // in str values getting empty
            }

updated code.

    public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
    {
        ItemFields fields = new ItemFields(component.Content, component.Schema);
        foreach (var items in fields)
        {
            if(items.ToString().Contains("www.blahblah.com"))
            {
                //throw pop up exception 
            }
            else{
                //save logic
            }
        }
    }

Using this code I am able to check whether the component field contains the URL or not. Bur problem is its works only for the text fields. How to read the data if the component field contains EmbeddedSchemaField, ComponentLinkField.

Any solution to catch this all filed in parent node level and read as string?

i tried the solution given but unable to get the result as expected
Source Link

Hello Friends I am trying to check or print the component values after the saving event is triggered.

I want to check on each component save. User added the www.blahblh.com URL or not then take action as per URL I am getting.

    public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
            {
                   Component comp = subject;
                    
                    string str = comp.Content.Value; // in str values getting empty
            }

updated code.

    public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
    {
        ItemFields fields = new ItemFields(component.Content, component.Schema);
        foreach (var items in fields)
        {
            if(items.ToString().Contains("www.blahblah.com"))
            {
                //throw pop up exception 
            }
            else{
                //save logic
            }
        }
    }

Using this code i am able to check the component field contain the url or not. Bur problem is its work only for textfield. How to read the data if component field contain EmbeddedSchemaField,ComponentLinkField. Any solution to catch this all filed in parent node level and read as string ?

Thanks in advance :)

Hello Friends I am trying to check or print the component values after the saving event is triggered.

I want to check on each component save. User added the www.blahblh.com URL or not then take action as per URL I am getting.

public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
        {
               Component comp = subject;
                
                string str = comp.Content.Value; // in str values getting empty
        }

Hello Friends I am trying to check or print the component values after the saving event is triggered.

I want to check on each component save. User added the www.blahblh.com URL or not then take action as per URL I am getting.

    public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
            {
                   Component comp = subject;
                    
                    string str = comp.Content.Value; // in str values getting empty
            }

updated code.

    public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
    {
        ItemFields fields = new ItemFields(component.Content, component.Schema);
        foreach (var items in fields)
        {
            if(items.ToString().Contains("www.blahblah.com"))
            {
                //throw pop up exception 
            }
            else{
                //save logic
            }
        }
    }

Using this code i am able to check the component field contain the url or not. Bur problem is its work only for textfield. How to read the data if component field contain EmbeddedSchemaField,ComponentLinkField. Any solution to catch this all filed in parent node level and read as string ?

Thanks in advance :)

deleted 15 characters in body
Source Link
Velmurugan
  • 8.2k
  • 2
  • 15
  • 27

Hello Friends iI am trying to check or print the component values after savethe saving event is triggered.

I want to check on each component save. User added the www.blahblh.com urlURL or not then take action as per urlURL I am getting.

public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
        {
               Component comp = subject;
                
                string str = comp.Content.Value; // in str values getting empty
        }

Thanks in advance :)

Hello Friends i am trying to check or print the component values after save event triggered.

I want to check on each component save. User added the www.blahblh.com url or not then take action as per url I am getting.

public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
        {
               Component comp = subject;
                
                string str = comp.Content.Value; // in str values getting empty
        }

Thanks in advance :)

Hello Friends I am trying to check or print the component values after the saving event is triggered.

I want to check on each component save. User added the www.blahblh.com URL or not then take action as per URL I am getting.

public void ComponentSaveAction(Component subject, SaveEventArgs args, EventPhases phase)
        {
               Component comp = subject;
                
                string str = comp.Content.Value; // in str values getting empty
        }
edited tags
Link
Loading
added 19 characters in body
Source Link
Loading
added 4 characters in body
Source Link
Loading
Source Link
Loading